#profanOS

1 messages · Page 1 of 1 (latest)

lunar jay
#

The profan Operating System is an independent OS developed from scratch. I started it in July of 2022, It's currently ~35000 lines of C

https://github.com/elydre/profanOS

The user interface and command line with the olivine shell but there is also a functional port of dash!

Some standard libs are available like libm, libz, etc and I also carry small programs like tcc, doom, lua :)

A web emulator based on v86 of copy is available with a history of all the versions: https://elydre.github.io/profan

Update may 2024

half raft
#

Here are the real hardware pics (sorry for the quality, i cant make it better beacause of my phone)

mortal ridge
#

thanks for sharing your profane OS

#

what do you mean by it having 'processing"

lunar jay
#

you can run multiple things in the same time (for example, a rotating cube, the shell, and a graphic game)

stuck tangle
#

How is that 19k lines

lunar jay
#

the librairies i guess

#

the math lib is 2900 lines (and ~20% complete ^^')

#

the multiprocess file in the kernel is ~1k

#

the window system is 1000

#

stdio 1k
stdlib 700
(and the 2 are 15-25% done)

#

and all of the headers and 500 lines files

#

it adds up very quickly

fickle creek
#

Have you considered porting an existing libc?

lunar jay
#

it's approximately what we are doing, but we need to adapt a lot of things

proper rose
#

what kind of libc do you want him to port, glibc?

#

(mlibc is 64-bit only as far as I know)

fickle creek
#

Mlibc considering someone is working on x86 support (or upgrade to 64 bit lol)

mortal ridge
fickle creek
#

Yes

mortal ridge
#

and i might take a look at mlibc for 68k some day

#

when i can comprehend whatever is going on in linux's headers for 68k, it's mad

lunar jay
#

we are porting tcc, currently the preprocessor is working

proper rose
#

also is that an I beam I see as the terminal console?

lunar jay
lunar jay
proper rose
proper rose
proper rose
fickle creek
#

We’re more than willing to add support for it

#

There is a PR for it already

#

Feel free to take that and finish it

proper rose
fickle creek
#

@proper rose ^

proper rose
#

i see

#

well i still kinda fear porting this

#

because iiuc it compiles its own compiler for userspace applications

fickle creek
#

You have a compiler for userspace no? Some gcc target?

#

If yes, retarget that

copper otter
#

use jinx

fickle creek
#

Not relevant at all

fickle creek
copper otter
fickle creek
#

Not really, but mlibc use is completely separate from xbstrap /jinx no?

#

Hell, you don’t have to use either

copper otter
#

of course

#

i was talking more in relation to having a sane way of managing userspace applications

#

since that was mentioned

fickle creek
#

I only saw libc being mentioned

#

So if it was, I missed it

copper otter
#

to be honest

#

i just read "userspace applications" and i typed "use jinx" because i'm just based like that

fickle creek
#

Figured

proper rose
#

i use the same compiler i use to compile the kernel

copper otter
#

so do i

#

but that compiler is the same i use to also build the userland

#

you don't really need (or want) a separate one

proper rose
#

by that I meant that I used a generic clang distribution in freestanding mode

fickle creek
#

Oh you probably want a target in there eventually

fickle creek
lunar jay
mortal ridge
proper rose
mortal ridge
#

i assumed things were fundamentally different between system servers and posix apps, but i didn't find it borne out so much when i investigated. if i remember rightly, anyway

lunar jay
lunar jay
proper rose
copper otter
#

the only reason they do that is as far as i am aware that they need no-red-zone libgcc? something like that?

#

even then, if you patch gcc to spit out a libgcc no-red-zone for multilib, it still builds the normal one so i don't know

#

also they just refuse to use the freestanding libgcc i have built by gh ci because "we don't want to hardcode compiler internals" despite it being practically 100% safe

#

(libgcc can and is often shared and the API hardly changes at all)

#

(sidenote, on managarm's broken libgcc/libstdc++ recipes they do not build and install shared libgcc as a target package)

lunar jay
proper rose
#

but what about block characters?

#

shouldn't you be storing a buffer of characters and their attributes anyways?

fickle creek
# proper rose why?

To set sane defaults instead of having a compile command line that’s 39583727 lines long

#

Among other things probably

proper rose
#

Its just a few switches for me

fickle creek
fickle creek
#

you might run into issues with porting software too if you use a generic elf target

proper rose
#

such as?

lunar jay
fickle creek
# proper rose such as?

Software might guard against configuring for a generic elf target (I’ve seen that before in autoconf stuff)

proper rose
#

autoconf sucks anyway ill just manually configure

#

the reason im so against making a special compiler for my OS is because of the gigabytes it would take

fickle creek
#

You do realize I mean the configure scripts made by autoconf

fickle creek
#

And/or hand rolled bullshit

proper rose
#

those suck

fickle creek
#

Agree

fickle creek
proper rose
#

It may be, but I really do not like compiling compilers like gcc

copper otter
#

i can compile it in 1 minute

proper rose
#

but im fairly sure it takes at least a gig for all its build artifacts

#

the problem aint build time, it's "bloat" from the build process

copper otter
#

lol

#

laughs in lyre

fickle creek
#

Prepare to cry in porting software

mortal ridge
#

it probably is workable until you have to deal with nontrivial build systems and can't throw your own makefile in

#

figuring out how to add the appropriate c- and ld-flags such that they're used in all the right places and potentially in the right order is pain

fickle creek
#

^

half raft
lunar jay
crimson bison
#

looks nice

hardy flicker
#

damn that looks more than nice

clear canyon
proper rose
#

there are very few hobby OSes that have any degree of graphics acceleration

clear canyon
proper rose
#

and graphics cards dont exactly tend to have their documentation public

#

I decided to try it out

#

Aside from the french keyboard layout I noticed it's actually missing keypresses sometimes

#

I tried to type "hello world"

#

text editor is also janky tripling my inputs sometimes

#

(its not a fault of my keyboard either, since it does the same with the on screen keyboard)

#

also, in the kernel shell, scrolling is really slow, takes a couple secs

lunar jay
lunar jay
proper rose
lunar jay
#

beginning of lua porting

lunar jay
proper rose
#

nice

frigid ridge
lunar jay
#

it would be cool especially to have better performance but for the moment I preferred to port the classic version of lua as it is reputed to be very easy to port

crimson bison
#

lua is a fun little lang

#

really portable since it's written in ansi c and really doesn't depend on much

lunar jay
#

all features work! lua shell, the require function and even a small bridge with the os to access the c library and syscall

#

the most difficult thing I encountered was a standard function header that was incorrect KEKW
memcpy(src, dest, n) while the official is memcpy(dest, src, n)...

#

I would definitely have to face the virtual memory, it becomes a real hell to find the bugs, the ls can literally break the processing if the malloc is too small troll2

proper rose
#

which is essentially the same as memmove()

lunar jay
lusty oasis
lunar jay
lunar jay
quartz star
proper rose
clear canyon
#

and it almost sound like windows

proper rose
#

I thought 💩 was "merde" in french

clear canyon
lunar jay
#

lua on profan 0.12.1 in real hardware with virtual memory (you can enjoy fingerprints)

lunar jay
#

doom work on real hw to!

#

now that there is virtual memory I will retry the port of tcc

#

it would definitely be super cool to code, compile, and run C without leaving profanOS

crimson bison
#

self-bootstrapping profan when?

lunar jay
lunar jay
#

https://wiki.osdev.org/PC_Speaker
osdev wiki code ported in... lua!

function play_sound(div)
    -- Set the PIT to the desired frequency

    profan.pout(0x43, 1, 0xb6)
    profan.pout(0x42, 1, div & 0xff)
    profan.pout(0x42, 1, (div >> 8) & 0xff)

    -- And play the sound using the PC speaker
    tmp = profan.pin(0x61, 1)
    if tmp ~= (tmp | 3) then
        profan.pout(0x61, 1, tmp | 3)
    end
end


function nosound()
    profan.pout(0x61, 1, profan.pin(0x61, 1) & 0xFC)
end

-- Make a beep
function beep(time)
    play_sound(1193) -- 1193180 // freq
    
    start = profan.ticks()
    while profan.ticks() - start < time do
        -- do nothing
    end
    
    nosound()
    -- set_PIT_2(old_frequency)
end

    
return {
    play_sound = play_sound,
    nosound = nosound,
    beep = beep,
}

it works in real hw x)

stuck tangle
#

In userspace?

mortal ridge
#

Pout 😾

crimson bison
#

lol

quartz star
#

add an r after the p in pout and you get a funny word in french

lunar jay
#

yes it's "port out" I hadn't even seen the pun

lunar jay
stuck tangle
#

What

proper rose
#

Let applications do whatever they want, including absolute pandemonium

lunar jay
#

(I know that this part of the code is ugly but some parts of the lua which allows to make more elegant code need standard C functions which are not yet implemented in profanOS)

#

and in any case the lua is not really a language made to make very elegant or compact code KEKW

crimson bison
#

one thing i want to know:
what are your thoughts on

func = function (variable)
  print(variable)
end

-- versus

function func(variable)
  print(variable)
end
lunar jay
#

the first writing in my opinion refers to anonymous functions (lambda in python) while the second and more traditional. I find that the second writing is more readable (being used to C) but the first allows small "hacks" in certain cases such as defining functions in an array (directly)
I'm not a big user of lua, it's a language I discovered recently as it's quite simple to port and fast on small machines/vm

crimson bison
#

yeah imo the 1st one looks a bit ugly, but it's the only way to have OOP-like classes

#

still pretty cool that lua has 1st class variable functions

lunar jay
#

I have something really strange with the use of the grub screen, a 1024x768 there is no problem (in vm or in rh) but in 1366x768 there is a 10 pixel offset. By modifying the kernel code by adding +10 the problem is solved but the resolution in profanOS retrieved from the multiboot info (with the addition of 10 pixels) is indeed 1376x768

#

default

#
uint32_t *framebuffer;
uint32_t fb_w, fb_h, fb_p;

void init_vesa() {
    framebuffer = (uint32_t *) mboot_get(22);
    fb_p = mboot_get(24);
    fb_w = mboot_get(25) + 10; // lul
    fb_h = mboot_get(26);
}

void vesa_set_pixel(int x, int y, uint32_t c) {
    framebuffer[y * fb_w + x] = c;
}

int vesa_get_width() {
    return (int) fb_w;
}

int vesa_get_height() {
    return (int) fb_h;
}
proper rose
#

you're supposed to use the framebuffer pitch

#

which is basically bytes per pixel

#

you can divide it by 4 and pray that there wont be any hardware that doesn't use a pitch divisible by 4

#

fb_p = mboot_get(24) / sizeof(uint32_t)

lunar jay
#

fb_p is 4 in 1024 and 1366

proper rose
#

wdym

lunar jay
mossy reef
#

so a few things

#

you will first want to use local

#

lua is global by default

#
function this_func_is_global() end
lunar jay
mossy reef
#
        if c == "C" or c == "D" or c == "E" or c == "F" or c == "G" or c == "A" or c == "B" then
            if next_c == "#" then
                c = c .. next_c
                i = i + 1
            elseif next_c == "b" then
                c = c .. next_c
                i = i + 1
            end
            play_sound(c, current_octave, current_duration)
        elseif c == " " then
            -- Do nothing
        elseif c == "w" then
            current_duration = 4000
        elseif c == "h" then
            current_duration = 2000
        elseif c == "q" then
            current_duration = 1000
        elseif c == "e" then
            current_duration = 500
        elseif c == "t" then
            current_duration = math.floor(current_duration * 2 / 3)
        elseif c == "." then
            current_duration = math.floor(current_duration * 3 / 2)
        elseif c == "4" then
            current_octave = 4
        elseif c == "5" then
            current_octave = 5
        elseif c == "6" then
            current_octave = 6
        elseif c == "7" then
            current_octave = 7
        elseif c == "8" then
            current_octave = 8
        elseif c == "9" then
            current_octave = 9
        else
            print("Unknown character: " .. c)
        end
``` this can bea a jump table
lunar jay
mossy reef
#

I’ll write up what I mean gimmie a min

lunar jay
mossy reef
#

Yes

lunar jay
#

noice

mossy reef
#

For lua

#

if it wasn’t supported then lua wouldn’t work

lunar jay
#

strtof for exemple is not implemented yet so float numbers in lua src can t be interpreted lul

proper rose
mossy reef
half raft
raven heron
#

bro built a slot machine

quartz star
#

lmao

#

bare metal casino lets gooooo

crimson bison
#

lol

hardy flicker
#

🍒 🍒 🥧

lunar jay
#

C build in profanOS!

proper rose
#

does TCC not have a built in linker

lunar jay
#

the tcc linker is very basic and works badly, I preferred to port a more complete linker (management of .ld files) than to spend time debugging the tcc linker

proper rose
#

I see

lunar jay
#

End of the development of a small homemade bash-like (easily portable) for the first anniversary of profanOS!
it supports variables, functions (in C or in the language itself) while/for/if/else, and has no memory loss
The user interface is pretty cool to use, with colors and autocomplete
Currently, there is no documentation but I will make one...

example of a small program to find prime numbers:

FOR n !(range 3 100)
 SET prime 1
 FOR i !(range 2 !n)
  IF !(eval !n ^ !i = 0)
   SET prime 0
   BREAK
  END
 END
 IF !prime
  echo !n
 END
END

and an example of a recursive tree function

FUNC tree
 IF !#
  FOR f !(find -f !0)
   echo !f
  END
  FOR d !(find -d !0)
   tree !d
  END
  RETURN
 END
 echo missing argument
END

some screen of the ui in profanOS:

lunar jay
frozen wadi
#

Very nice!

#

Recurcive variables substitution is supported like in PHP.
=> Recursive

#

Anyway looks good, does it have something like PATH or do you always have to use the absolute file path

lunar jay
lunar jay
#

process manager mass reliability test with doom

proper rose
# lunar jay

well it seems you are running a lot of qemu's with doom, so really you're hosting your host's performance

lunar jay
#

yes it's a realy nice computer

lunar jay
#

profanOS 1.0 is released with a brand new home-made filesystem that supports special files (like /dev/zero in linux for example)
the main terminal emulator is no longer that of the kernel and can also handle other display fonts (.psf files)
I also take the opportunity to improve something like some commands that manage the arguments

#

small demo of the stdout redirect to the serial port, we must go through /dev/nocolor to remove the profan color codes ($1: green, $2: blue..), they will soon be replaced by the ansi stadard color codes

weak hazel
#

Whoa nice work

lunar jay
#

THANKS!

hot shore
#

good job!

hot shore
# lunar jay

go. Is that golang's toolchain? Or something else

lunar jay
hot shore
#

weird choice tbh

lunar jay
#

the choice comes from the very beginning of the OS and I have kept the same way of launching programs there will always be time to change it or to call the go language with the golang command LiPerformDelisquesceUponObjectW

hot shore
#

I would personally name such command something like exec. But that's my preference

lunar jay
#

yeah, exec was already taken to interpret files in olivine (the bash like in question)

hot shore
#

uh

#

why no shellbang?

lunar jay
#

there are many shell languages already existing but I preferred to make mine which will be better integrated into the profanOS environment and easier to modify little by little to follow the updates of the OS

lunar jay
#

I was using profan and needed a sleep command but realized there was none so I coded it directly on profanOS in real hardware. It was kind of fun to 'really' need the tools in compilation.

#

(sorry for the poor quality of the photos the screen is very bright and the room is quite dark)

proper rose
#

Second, printf("Usage: %s <ms>", argv[0]);

proper rose
#

but anyways, nice compile

lunar jay
#

indeed for the moment the arguments are not standard but I will soon change it

proper rose
#

can't you give it in the actual first argument if you need it

#

like /user, args, lalala, hi

#

also I'd give the running program the alias we used instead of the underlying path

#

if you run gcc like you usually do, you are going to see gcc, but if you run /usr/bin/gcc you are going to see that it also says /usr/bin/gcc

lunar jay
#

the current path will be stored in an environment variable and the aliases are managed in my programming language and there is the possibility of retrieving the command line before the substitution

#

the longest will be to modify all the tools so that they work with the new arguments

lunar jay
#

standard arguments and environment variables!

#

test command src:

int main(void) {
    printf("PWD : %s\n", getenv("PWD"));
    printf("DEMO: %s\n", getenv("DEMO"));
    return 0;
}
lunar jay
#

a friend challenged me to build his programming language in my OS

#

the link is quite long as the linker is vlink and it is not very fast

lunar jay
#

thanks tuxyay

stray ferry
lunar jay
proper rose
#

My OS has an e command which executes an executable at a path, but it's been superseded by a direct command to run

#

If no builtin commands match it tries to run /Bin/xx.nse where xx is the command you typed

stray ferry
#

my shell checks first if the command is a builtin, if it isn't it checks the cwd and if that fails it looks in the path

proper rose
lunar jay
#

I implemented a selection of keyboard layout in profanOS, we can easily change it with kb <keymap> for example kb qwerty the key config files are in /zada/keymap and are editable, I hope this will make profanOS easier to use

#

by default, it is azerty

dreamy egret
#

is qwertz supported?

lunar jay
#

not currently but I can add the layout very easily

dreamy egret
#

its jsut qwerty but y amd z are swapped

#

so yw

frigid ridge
#

its also known as the cringe layout

#

or the one they use in germany

frozen wadi
#

best layout

dreamy egret
frigid ridge
#

it makes no sense for english anyway

raven heron
dreamy egret
#

profanity os

lunar jay
#

I implemented pipes in olivine!

#

more and more commands manage flags too

#

they are not always standards KEKW

#

I fixed a lot of small bugs, profanOS almost no longer crashes

#

there is some obscure functionality to retrieve the contents of stdout in a variable for example

#

I should definitely write documentation / a guide that explains the features of profanOS

lunar jay
#

profanOS in an x86 emulator in... profanOS

proper rose
#

nice! good job

lunar jay
copper otter
#

mb2?

lunar jay
#

multiboot 1 is sufficient but version 2 also works it seems to me

copper otter
#

also i just noticed that's limine 3.0

#

that's a bit old lmao

lunar jay
#

I added a small shell alongside olivine (https://elydre.github.io/md/olivine) named lish (for lite shell or like bash).
lish supports quotes " and ', redirects, heardocs, pipes (like bash), enviroment variables and integrates some builtins.
This shell is an improved port of the "minishell" project from 42 school...
Olivine will remain the default shell for these functionalities (loop, condition, function)

lunar jay
#

the old lib system was replaced by dynamic libraries!
the dlfcn functions work too :)

lunar jay
#

small tcc test with the rebuild of libC in profanOS

lunar jay
#

I've been wanting a POSIX compliant shell in profanOS alongside olivine for a long time, and it's done with a dash port!

#

in the future I will probably make a colored text entry zone and with auto-competition

midnight solstice
#

wasd becomes zqsd

lunar jay
#

the kb qwerty command change it to qwerty

midnight solstice
#

i'm clearly doing something wrong here

lunar jay
#

oh x)
exec allows you to execute olivine scripts (the shell language) to launch binary you must use .

#

like . /path/to/file.elf

midnight solstice
lunar jay
#

F2

#

it's like ctrl+C

midnight solstice
#

also i like how the shell doesn't render itself again every 2 microseconds

#

you can even see leftover pieces of the cube after you clear the screen

lunar jay
#

there is no window manager yet but the xclear command does a real clear

lunar jay
#

I haven't posted a message here in a while, but profanOS is still active and well making good progress! The libc is more and more complete, the kernel is stable (pretty much thinkong) and there are ports of lots of cool stuff like python 3.11, GNU-make, perl, etc..
For 2025 I'm going to try to document the project a bit more by sharing new features every month.
The January post is right here: https://github.com/elydre/profanOS/discussions/73

#

I've received some lovely messages and I'm very grateful to this community !

lethal crater
lunar jay
#

and on smartphone the keyboard does not appear in the online emulator but that is another problem