#EvalynOS

1 messages · Page 8 of 1

hazy saddle
#

I am back to the original way with the timer calling the schedular

#

I have got stack smashing protection implemented now and I made the panic work a bit better

#

It now goes through assembly for panics not from interupts

#

And it will build a frame and pass it to the function for interupts

#

So it’s a lot cleaner for things

rotund furnace
#

no error code for gpf :P

#

oh nvm you do print the error code

#

selector index 4 in your gdt is cooked

#

or not wtf why is bit 16 set?

hazy saddle
rotund furnace
#

idk something is broken

rotund furnace
#

ignore it

rotund furnace
#

for now atleast

#

the errorcode is trashed for some reason

#

oh found it

#

error > 16

#

😭

hazy saddle
#

XD

#

why tf is that there

#

how did that get there

#

how long as that been there

rotund furnace
#

i assume that's meant to be >>

hazy saddle
#

yup

#

here we go thats better 💀

rotund furnace
#

alright

#

so yeah selector index 4 in your gdt is borked

hazy saddle
#

Il push to git tomorrow with that fix if this isn’t fixed tonight

#

Sleeping in about an hour

hazy saddle
rotund furnace
#

lemme check

#

uhhh

#

why are your limits 0

#

aren't they meant to be 0xfffff

hazy saddle
#

They are ignored on 64bit though right

rotund furnace
#

maybe

#

yeah

#

also npf has binary support btw

hazy saddle
#

Oh shit really

rotund furnace
#

yeah

hazy saddle
#

@rotund furnace also still dies

hazy saddle
rotund furnace
#

works on my macine 😭

hazy saddle
#

WHAT

rotund furnace
#

unless you didn't push something

hazy saddle
#

Dev branch is up to date

rotund furnace
#

😭

#

I cloned dev lmao

hazy saddle
#

What the fuck 😭

#

@rotund furnace Does it run on real hardware?

rotund furnace
#

I'll have to check

hazy saddle
#

Is this a fucking distribution or qemu or toolchain bug?

#

Everyone has been banging at thier computer over this

#

AND IT WORKS FOR YOU 😭

rotund furnace
hazy saddle
#

@devout path @viral bison look at this shit XD

rotund furnace
#

how do you boot this shit on real hardware

hazy saddle
#

@rotund furnace To be fair it did make me add a good chunk of debugging shit for the dev branch

rotund furnace
#

you don't make an iso file

hazy saddle
#

And copy over the EFI folder the limine config the kernel.elf and initramfs

rotund furnace
#

kk

hazy saddle
#

@rotund furnace What’s the prognosis doc?

rotund furnace
#

im dealing with linux being stupid hold on

hazy saddle
#

All good

rotund furnace
#

ok well the usb drive I tried it on is dead ig

hazy saddle
rotund furnace
#

what the fuck why is this shit so broken

#

ok well it has the files on it so fuck it

hazy saddle
#

How long is it running

#

It’s actualy stable?

#

Can you run bad apple twice to have two of them on?

rotund furnace
#

how the fuck do I run it twice lmao

hazy saddle
#

Even if the logs fly by it should still track key presses right

rotund furnace
#

oh lmao

hazy saddle
#

Just do “badapple” again

rotund furnace
#

ah it fails on my macbook

#

it doesn't even boot

hazy saddle
#

MacBooks don’t have a PIT

rotund furnace
#

(intel mac)

hazy saddle
#

Iirc

rotund furnace
#

oh it failed on serial

hazy saddle
#

Lmao

hazy saddle
#

What’s wrong with my computer

hazy saddle
#

I wana check if it’s my QEMU or if it’s my compiler toolchain

rotund furnace
#

let me see if it finishes

hazy saddle
#

It will loop btw

rotund furnace
#

oh

hazy saddle
#

I don’t have a way for apps to uhhh exit

rotund furnace
#

well if it does that's a success ig

hazy saddle
#

But now I’m scared on what the fix it to get it working for my PC

rotund furnace
#

so idk

#

mines smaller????

#

anyway yeah using that binary works

#

and it's looped like once or twice by now

hazy saddle
#

Huh

#

Thats the one I complied with a few changes for the GDT

#

And some formatting changes

#

So WTF

rotund furnace
#

well it works on my machine lmao

hazy saddle
#

What’s your kernel version and QEMU version and destro?

rotund furnace
#

qemu-system-x86_64 -version?

rotund furnace
hazy saddle
#

6.18.1-2-cachyos
QEMU emulator version 10.1.2

#

What the fuck

rotund furnace
#

LMAO

#

my kernel is out of date

#

on a rolling release distro

hazy saddle
#

Do an update XD

rotund furnace
#

yeah you right

hazy saddle
#

oh shit

#

Free gigabyte of storage space thank you

#

@rotund furnace I mean it’s also broken on TCG

#

So fat chance it’s a Linux kernel bug right

rotund furnace
#

hmmm what

hazy saddle
#

(Imagine if we found a Linux kernel bug)

hazy saddle
rotund furnace
#

with tcg

hazy saddle
#

what

#

the

#

fuck

#

Did you do the kernel upgrade and reboot and test?

rotund furnace
#

it gonna take a while to update my shit rq

hazy saddle
#

We are both on the same distro and it should fucking work

rotund furnace
#

not a problem on nixos btw

hazy saddle
#

Immutable or somthing

rotund furnace
#

wait but does it work on real hardware for you?

hazy saddle
#

I don’t have a USB stick

#

It’s fine

#

Gone

rotund furnace
#

damn

hazy saddle
#

I’m on a 5700x tho

rotund furnace
#

im on a i7-11700

#

I feel like that wouldn't change anything

hazy saddle
#

Yeah

rotund furnace
#

that would be crazy if it did

hazy saddle
#

Plus syscall/stsret is an amd64 thing

#

That was adopted by Intel

rotund furnace
#

after they ditched sysenter/sysexit

#

oh well

#

stange

#

im updating 600 packages atm

hazy saddle
#

I have 1gbps internet so it’s fast as fuck unless you have one bloated ass package looks at amd rocm

rotund furnace
#

AHAHAHAHAH

hazy saddle
#

And it’s symmetrical fiber too

rotund furnace
#

gigabit

#

if only

hazy saddle
#

I used to be on 10mbps upload for years

rotund furnace
#

so uh quick question what do you do on boot failure

#

because I forgot to shutdown my laptop

#

and now it's hot to the touch lmao

hazy saddle
rotund furnace
#

wait it died on serial

#

which isn't fatal

#

oh it spun somewhere

#

im gonna assume ps2 setup because it's right after

hazy saddle
#

Ohhh it’s probaly stuck spinning checking serial port?

rotund furnace
#

no it printed that it failed to init serial

hazy saddle
#

If there is no seriel port it says that

#

It’s prolly this

#

Because I don’t have a timeout here

rotund furnace
#

oh prob

#

😭

#

yeah just burn my cpu while you are at it

hazy saddle
#

SORRY 😭

#

I think I did leave off some halts on critical panics as a way to detect if it crashed while you were away

#

“If the fans are loud something is prolly wrong”

#

(Not the best idea)

rotund furnace
#

MY MACBOOK DOESN'T HAVE FANS

#

😭

hazy saddle
#

I also have a way to make the kernel panic make a Wii noise when it dies

rotund furnace
#

that also wouldn't work on my pc because the fans are also at 100% always

hazy saddle
#

If the panic handler panics you can have it make a noise like this

rotund furnace
hazy saddle
#

@rotund furnace How did the update go

rotund furnace
#

oh it just finished

#

sick

#

now I gotta update my hyprland plugins 😭

#

yeah it still works

#

I even rebuilt and it still works

hazy saddle
#

The fuck

#

What’s wrong with my computer

rotund furnace
#

lmao

hazy saddle
#

@rotund furnace How do I switch to the dev branch and get the proper files?

#

Because I cloned it and switched to dev and it dosnt have the updates

rotund furnace
#

iirc you need to pull after switching

hazy saddle
#

I did a reset and it worked

rotund furnace
#

the kernel?

hazy saddle
#

And it’s still fucked

#

The kernel broke

rotund furnace
#

wtf?

hazy saddle
#

I updates all my packages

rotund furnace
hazy saddle
rotund furnace
#

cpu bug?

hazy saddle
#

Shits bad

hazy saddle
rotund furnace
#

nah

#

wouldn't be

#

something must be broken

hazy saddle
#

Who do we talk to about this

#

I feel like this is above my pay grade

rotund furnace
#

I would help but I can't even reproduce the bug?

#

try cloning the repo on the dev branch and seeing if that works

hazy saddle
#

Do you have any amd systems on zen3?

rotund furnace
hazy saddle
#

I did try dev branch clean

#

@rotund furnace

#

still fucked

rotund furnace
#

what the fuck

hazy saddle
#

I did this with your exact command

#

Then cd into the folder

#

And then make

rotund furnace
#

oh the error code is broken again 😭

hazy saddle
#

What 😭

#

Oh that wasn’t pushed yet

#

The > 16 to >>16

rotund furnace
#

oh yeah it's broken in my build as well

hazy saddle
#

So uhhhh well shit

rotund furnace
#

yeah

#

uh

#

very much

hazy saddle
#

I’m cursed?

#

My code is an SCP now?

#

SCP 0xdeadbeef

rotund furnace
#

because it seems like a qemu problem if not even tcg works

hazy saddle
#

which qrmu package did you get

rotund furnace
hazy saddle
rotund furnace
#

what the fuck

hazy saddle
#
sudo pacman -Rs qemu-full 
sudo pacman -S qemu-full
#

That’s what I did

rotund furnace
#

😭

hazy saddle
#

@rotund furnace On a scale of one to 10 how fucked am I

rotund furnace
hazy saddle
#

My kernel has Ligma

devout path
#

y was i mentioned here xd

devout path
hazy saddle
#

but work for water

#

@rotund furnace it works in TCG for me now

#

just not KVM

rotund furnace
#

what the fuck

devout path
#

What the hell is happening to ur kernel

hazy saddle
dense cargo
#

rainbow kernel panic

hazy saddle
#

alright i am back to do more work

#

im gonna checkout an older commit before i redid interupts

#

just to see if somthings iffy with thoes

#

im on commit a84fd7997a integrating newer code and ive got the GDT in and i found some potental issues with it now as i had to change some stuff

hazy saddle
#

yeah idk where i was goin with that. i dont have half the things i need there because of pure c based innterupts yaaar

hazy saddle
#

thats an uhh not so happy stack for sysretq

#

it somehow diddnt fault on that?

#

ohh thats sysretq

#

not iretq

#

why is it working if i single step in GDB yaaar
and it skips over the syscalls and wont show me what happens when the IP changes

#

@rotund furnace you mentioned it worked on real hardware before right? leme test this myself

#

it only crashed when i put continue??

#

Yeah it crashes on real hardware for me @rotund furnace

#

Let me test on an Intel machine

rotund furnace
#

I think you are doing some ub fuckery that just works on intel

#

I don't have any amd hardware so I can't test that

hazy saddle
#

But my mom isn’t responding and she is the only one with an Intel laptop

rotund furnace
#

thats like the only thing I can think of

#

it would have to be some fucking ub that causes something

hazy saddle
#

But what about TCG

rotund furnace
#

hm

#

yeah

hazy saddle
#

@rotund furnace I did get an ISO file generated manually and I may automate it soon but I sent it to some friends to test

#

Gonna try and get a better sample size

#

It did triple fault on KVM on my laptop too @rotund furnace

#

Which is strange

#

Just right away

#

Let me see how it goes on my laptop bare metal

rotund furnace
#

maybe implement ubsan and see if that says anything?

hazy saddle
#

Damn my laptops USB ports are being funky

hazy saddle
#

I did get stack smashing protection stuff added

rotund furnace
#

just add -fsanitize=undefined to your compiler flags

#

then just implement all the functions it tries to link in but fails because you don't have the lib for it in freestanding

#

you also should add __attribute__((no_sanitize("undefined"))) on the ubsan functions

hazy saddle
#

The ISO won’t boot on any other machine

hazy saddle
#

Why is the drive stick at 6MB max now

#

Stuck

#

WTF

#

Nvm gparted bug

#

@rotund furnace Yup it works on Intel

#

I wonder if anyone else has had this kind of issue?

#

I doubt I can google syscall amd vs intel because of the 32bit thing

rotund furnace
#

wait does it crash on sysexit???

hazy saddle
#

iretq

rotund furnace
#

oh

hazy saddle
#

@rotund furnace what arguments should they be taking?

rotund furnace
#

oh because in the amd manual it says

#

and you don't do that

hazy saddle
#

whats RPL again? thats the MSR right

rotund furnace
#

the rpl bits of the selector iirc

hazy saddle
#

that would be when doing GDT things right and changig thoes

rotund furnace
#

well it's telling you that for the IA32_STAR msr you need to set the rpl of the ring3 selectors to 11b

#

and you don't do that

#

so maybe you should

hazy saddle
#

should my panic also be unsanitised

rotund furnace
#

uh maybe

hazy saddle
rotund furnace
#

yeah

hazy saddle
#

leme finish UBASAN

#

its good to have anyways

#

UBASAN is not hit

hazy saddle
rotund furnace
#

for what?

hazy saddle
#

like to get the hex value to OR with

rotund furnace
#

oh python ig

hazy saddle
#

i mean like to select checkboxes for bit numbers

rotund furnace
#

oh

hazy saddle
#

i dont wana do like 0b00000001100000000 or some thing

rotund furnace
#

and that's pretty nice

hazy saddle
#

danke

#

here we go

#

HOLY SHIT

#

IT WORKS

rotund furnace
#

intel doesn't say anything about having to set the rpl to r3

#

fr?

#

what did you change

hazy saddle
rotund furnace
#

ohhh

#

you could like

#

not do that

hazy saddle
#

Just the OR

rotund furnace
#

and just do (0x18 | 3) << 48

hazy saddle
rotund furnace
#

this is why you keep both the intel and amd manuals on standby

#

intel clearly doesn't give a shit if you load a ring0 selector

hazy saddle
#

AMD certainly gives a shit though

#

Too many shits

#

Too many god damn shits

rotund furnace
#

I mean

#

amd made syscall/sysret

hazy saddle
#

True

rotund furnace
#

so they are in the right here and intel is wrong

hazy saddle
#

atleast this made me get stackguards and UBASAN

#

And UBASAN catches it before the stack smashing protector

rotund furnace
#

so there is ub 😭

hazy saddle
#

That’s the command that triggers UB

#

On purpose

rotund furnace
#

oh

hazy saddle
#

I have to test it to make sure it works

#

@rotund furnace thanks for helping me find this

#

i would of never found this due to my team redness heh

#

@rotund furnace i wonder why it was so intermitent and heisen bug like though

#

but holy shit i can actualy start work on a real userspace and libc and stuff

rotund furnace
#

All good

hazy saddle
rotund furnace
#

This is why you test on more then just intel or amd

#

I mean too be fair it only works on intel because they implemented it wrong

severe marlin
rotund furnace
severe marlin
#

Yeah but the out of context bit

rotund furnace
#

Oh

hazy saddle
#

Yeah USA

#

But yeah I meant AMD

#

What’s funny is my first laptop had an AMD APU

#

Second laptop I get with an Intel CPU and an nvidia GPU

#

The screen is busted in a few days nothing I did

severe marlin
#

Yeah fair I'm also on amd

hazy saddle
#

I had to return it and I got my current AMD laptop with an nvdida GPU

#

And now I have an AMD desktop CPU and GPU

severe marlin
#

I have an amd + nvidia desktop and then now an amd + integrated laptop as well

#

But my old laptop was intel and then the power button stopped working

#

I was full ready to replace the button and solder on a new one but unfortunately it was an issue in the motherboard somewhere and the button itself was fine

mild glacier
# hazy saddle

imagine that ascii art being your "oops! kernel panic! system will now explode-"

hazy saddle
#

That is my kernel panic ascii art lol

hazy saddle
# hazy saddle

This is a kernel panic triggered by undefined behavior sanitization

hazy saddle
#

@rotund furnace It’s now on codeberg and my git server

Thank you git merge —squash

hazy saddle
#

its building at the very least for my kernel
-rwxr-xr-x 1 evalyn evalyn 13M Dec 23 20:41 ./doomgeneric

#

yeah but no

#

maybe i should just use mlibc

#

instead of whatever the fuck this jank is

mild glacier
mild glacier
hazy saddle
#

you manualy parition a USB and drop files on it

mild glacier
#

sounds like my solution to a distro
just throw files into a partition and boot it via GRUB lol

hazy saddle
#

i use an 8x8 font size

mild glacier
hazy saddle
#

or it can be

mild glacier
hazy saddle
#

i have a raw frame buffer

mild glacier
#

ooo

hazy saddle
#
  • limine
mild glacier
hazy saddle
#

and flanterm and nanoprintf give you proper tty stuff

#

i did have my own implementations before

#

but they werent as good / complete

hazy saddle
#

The cross compiler can be built properly now!

#

I just have to finish porting mlibc and making an elf loader

hazy saddle
#

iso generation is working

#

the new GCC is now building apps for the kernel properly with mlibc

#

i just need to make a basic elf loader now

hazy saddle
#

eyyy the first header is getting parsed

mild glacier
hazy saddle
#

being (8.8 mebibytes) / (1.44 megabytes)

mild glacier
mild glacier
hazy saddle
#

but my elf loader is elfing

mild glacier
#

oh wait um

hazy saddle
#

but the libc isnt libcing

mild glacier
hazy saddle
mild glacier
#

EvalynOS is a real OS now o7

hazy saddle
#

not until doom

#

which needs my libc to work

#

its being funky

mild glacier
#

i need video footage of EvalynOS playing Bad Apple pls

hazy saddle
#

I have a video somewhere

hazy saddle
hazy saddle
#

IVE DONE DID IT

#

MLIBC IS PORTED!

hazy saddle
hazy saddle
#

And it reads in pairs

#

First byte is how many pixels to draw

#

Second byte is the color

#

It’s run length encoding

#

And I formatted bad apple to be purely black and white so it could compress losslessly decently with this

mild glacier
# hazy saddle It’s run length encoding

oh damn RLE
i should use that for my text distro video graphics
but i would do it like so:
bit 1 = color, bits 7-8 = amount then an optional byte for the type of block
e.g. 0b10101010 = print white 42 times in a row
for monochrome coloring :D

hazy saddle
mild glacier
hazy saddle
#

If it’s a protocol for sending to a terminal RLE wouldn’t be too useful

#

This is used to compress it so it takes up less space on disk

neon drum
#

Keybard

mild glacier
hazy saddle
hazy saddle
neon drum
#

But eh, idk

hazy saddle
neon drum
hazy saddle
#

Others hadn’t had the same issue either

#

But ehhh

#

It’s my OS XD

neon drum
#

Real lmao

hazy saddle
#

But yeah doom is working a now

#

Discord

#

Please send video

hazy saddle
#

Alright it’s all working good and it’s on my personal git site and not codeberg rn

#

Gonna finish up some docs and maybe push to main or keep working on dev

mild glacier
#

evalyn os will never be doomed ||hehe dad joke||

#

can u make one of those animations that u can never see when u screenshot/stop

mild glacier
hazy saddle
#

The bad apple demo only writes pixels that have been changes since the last frame

mild glacier
hazy saddle
#

And soon always writes the entire frame regardless

#

I mean that’s not really important to do when there are bigger fish to fry lol

mild glacier
hazy saddle
#
  • it might be trivial with the libc
mild glacier
#

i just need to find out where and how to write directly to an FB with uhh... linux 😭

hazy saddle
#

That’s what I based my on partially too

mild glacier
#

but is it open source?

hazy saddle
#

Yes?

#

That’s why I was able to port it

mild glacier
#

oh ok 👍

#

link?

hazy saddle
mild glacier
neon drum
sudden mirage
#

thats a bad way to do it, it cloberrs rdi and rsi

hazy saddle
#

Do you know what syscall/sysret is

mild glacier
hazy saddle
hazy saddle
#

They clobber RCX and R11

#

RCX holds the RIP

#

R11 has the masked flags

#

And sysret uses those registers to return

#

And you manually handle RSP

#

Eg the stack

rotund furnace
#

Which is clearly better then pushing them

hazy saddle
#

Well you would push them on the syscall routine yourself

#

That you make

#

Or store them in a certain spot etc

rotund furnace
#

I mean like the cpu pushing them

hazy saddle
#

Ahh yeah yeah

#

What is @sudden mirage on about it clobbering rdi and rsi?

rotund furnace
#

No clue

hazy saddle
#

Because if it was I don’t think my kernel would be running doom right now

#

And calling system calls a whole lot to do so

#

@rotund furnace Mind if I DM you btw?

rotund furnace
sudden mirage
# hazy saddle Do you know what syscall/sysret is

yes, but but when you invoke a syscall with your function it literally clobbers rdi and rsi because the syscall num and a is passed to this func, and afaik gcc wont preserve the other regs, i dont even thing inlining would do a difference if you think it will, so the best option is to pass the syscall args to the func

hazy saddle
# sudden mirage yes, but but when you invoke a syscall with your function it literally clobbers ...

are you aware that my kernels regular build has a diffrent systemcall ABI to Linux?

I pass the systemcall number to RAX
And j get the return value into RAX with other arguments in different registers.

If this function were wrong none of my code would be working.

You replied to a message from like 2 weeks ago when things were broken from a a completely diffrent issue.

They are working now with doom executing properly and a libc ontop.

#

Also that systemcall function takes in the two arguments. For the systemcall number and one parameter. It’s not taking them from some random place.

sudden mirage
#

mb

hazy saddle
hazy saddle
#

@sudden mirage can i ask that you dont come to this thread again please?

mild glacier
#

good meme? 🔥

hazy saddle
#

@rotund furnace sleep works!

#

your laptop will stop burning

#

The timing on bad apple is fucked tho

#

That code is a complete and utter mess tho

#

Well it’s mostly fine

#

But a little desynced

#

To be fair I got the audio data from the MSDOS version and the frame and audio timings they do is ASS

hazy saddle
hazy saddle
#

Doom and bad apple

#

Before fucking sleep

floral kettle
hazy saddle
#

I mean it’s also both irl sleep and kernel sleep XD

floral kettle
#

ah you were talking about kernel sleep lol

hazy saddle
#

Yup

#

I now have proper idle threads and sleep() functions lol

floral kettle
#

nice

#

reminds me of the pain that implementing forcefully unblocking sleeping threads for the first time was, I had multiple deadlocks that'd randomly sometimes happen in my initial impl KEKW

hazy saddle
#

My sleep is implemented by my scheduler checking if the wakeup time is more than the current time.
If it’s higher find the next task

#

And il add waitfd and waitpid similar
If conditions not met skip

#

I had a bunch of issues too but I got it in the end XD

floral kettle
#

what I was talking about was for like waiting on an event with a timeout

hazy saddle
#

Ahhh

#

Wait how’s that work / where is that used?

floral kettle
#

if its only the scheduler unblocking threads when their sleep expires its not that bad but when an arbitrary random thread on a random cpu can wake up a sleeping thread at any point you have to be careful with locking

#

its used in eg. posix poll() or any other function that accepts a timeout

#

or well I guess it might depend on how exactly you implement it but at least the way I did it

hazy saddle
#

Ahhh. So waiting on a thing and if a timeout happens wake it up still too?
I could have it do IPC to tell the schedular PID X needs to wakeup or other.

And when checking if the thing is read also do a time check?

#

I don’t do SMP yet though

#

I’m probably gonna do that after @devout path finishes SATA and a filesystem as to not cause too many internal reworks as they work on that

floral kettle
#

yeah so that the thread can either get woken up when something is done or a timeout expires

hazy saddle
#

Yup yup

#

I’m trying to keep my intentions basic as to make my code easy to reference for others and me

#

So I’m not wanting to do tooooo many fancy things

hazy saddle
#

and way less for bad apple

#

i will want to get waitfd to wait for new data on them for the "kernel shell" to be more reponsive

#

but i may aswell get system() workin first

#

and then do waitfd

#

or is it poll?

#

yes i need poll

devout path
#

hi

hazy saddle
mild glacier
opaque marten
#

what cpu do you have

hazy saddle
opaque marten
#

do you have polling

#

also i have a 5800x and it uses like 5-15% iirc

hazy saddle
#

It only checks input once per frame and if it needs to grab an extended key it polls. Although I can probably insert a sleep in there?

opaque marten
#

dunno

hazy saddle
#

And if it dosnt get input it just directly goes to the next

#

And it makes sure the buffer is empty

hazy saddle
#

And it seems under KVM the core won’t down clock

#

The bad apple demo running at a few %

#

It still shows a high clock speed

#

So I presume it’s some other fuckery

opaque marten
#

idk then

hazy saddle
#

Okay so let me get my road map here
Get a bare minimum shell working in userspace to launch apps.
Redo the PMM VMM and Heap
make copying to and from userspace safe
Look into signals and pipes and making things more posix
Get CoW and fork() and others working nicely
Port bash
Port other things

Port x11

#

@opaque marten think i fixed the cpu usage tho

#

wait btop shows it differently yaaar

#

i thought the clis and stis were causin it

#

but i did get all sti/cli's goned

hazy saddle
#

Today I am going to get started on parsing the basic ACPI tables to get the IOAPIC and APIC stuff working to get away from the PIT

Aswell to move some folders around and push the dev branch to main

rotund furnace
#

please

#

just save your self the effort

#

use uacpi (in barebones mode if you don't needa parse aml)

#

lest you go down the rabbit hole of aml

hazy saddle
#

Not AML god no

#

Just the basic ass tables

hazy saddle
#

The docs scared me

#

Like @rotund furnace How hard is it for just barebones mode rn

onyx comet
#

how do you handle the bad apple video? do you parse it yourself or use a 3rd party lib? and if you do it yourself, which format? :D

rotund furnace
#

it's 4 functions

#

one for getting the PHYSICAL address of the rsdp

#

one for mapping physical memory to virtual memory (you decide the address)

#

one for unmapping (it gives you in the virtual address you gave it)

#

and one for logging

#

that's it for barebones mode

#

it's like 36 loc for my impl

magic saffron
#

imo if you just want the tables adding uacpi is overkill

hazy saddle
hazy saddle
magic saffron
#

it does have a nice header you can include to save yourself writing the definitions

rotund furnace
rotund furnace
#

ig

#

but if you want aml down the line it's easy

rotund furnace
#

tbf I can prob replace it with my own parser because I'm gonna do aml in userspace anyway

#

(hopefully)

#

we need like a uacpi stripped down version that's JUST parsing 😭

magic saffron
#

well we have that, its called uacpi in barebones mode 😛

rotund furnace
#

yeah ig

hazy saddle
#

I mean the tables are just a couple structs

hazy saddle
#

Would take me two hours tops

rotund furnace
#

yeah but if you wanna do aml at some point you're gonna have to rip it all up

magic saffron
#

nah you can have both

#

you'll need tables earlier than aml

hazy saddle
#

Can’t believe I have to implement x2apic just because Intel got rid of the pic (and Apple I think?)

hazy saddle
rotund furnace
#

because some machines don't have apic

#

but also some of the machines that have x2apic don't have apic

#

🙃

#

but apic/x2apic shit is generic

hazy saddle
#

It’s the same driver except one is MSRs and the other is MMIO right?

magic saffron
#

more or less

rotund furnace
#

yeah x2 is msr

magic saffron
#

there's one special case where ICR (register for sending IPIs) is a single register now instead of two

rotund furnace
#

that ig

#

otherwise you can just do something like


uint32_t lapic_read(uint32_t reg) {
    if(x2apic_mode) {
        return (uint32_t) __rdmsr(IA32_X2APIC_BASE_MSR + (reg >> 4));
    } else {
        return mmio_read_u32(apic_base_address + reg);
    }
}

void lapic_write(uint32_t reg, uint32_t value) {
    if(x2apic_mode) {
        __wrmsr(IA32_X2APIC_BASE_MSR + (reg >> 4), value);
    } else {
        mmio_write_u32(apic_base_address + reg, value);
    }
}
hazy saddle
hazy saddle
#

I’m not gonna be doing SMP yet

rotund furnace
#

how do you do ipis?

hazy saddle
#

But a timer that’s more precise than the PIT would be nice for nanosecond sleep stuff

rotund furnace
#

see I only use the apic timer for scheduling

#

I calibrate it with the pit 😭

magic saffron
#

if you're planning smp support at all, I'd recommend getting that setup asap. It'll change a lot of assumptions you can make and you'll encounter different bugs.

rotund furnace
#

^^

hazy saddle
#

I’m atleast gonna wait for @devout path to finish the sata and ext2/4 driver as it will take a ton of reworks

hazy saddle
#

And implementing thread local storage for threads

magic saffron
hazy saddle
#

For locks I should make arch specific ones and then have a macros that calls the proper arch one I think? With some pre processor statements right

magic saffron
#

you can do it generically with atomics

#

gcc/clang have builtin functions for them

hazy saddle
#

I can also probably use plain atomics for some things too?

#

But like anything two cores may wish to touch should have locks

rancid viper
#

generally though

#

throwing locks on things is the easy way out

magic saffron
#

its a good way to start: wrap any shared state in a lock

hazy saddle
#

Aswell for my scheduler I was thinking for cross core that threads would compare how many threads they have weighted by sleep and then pass threads between cores to make sure they are balanced.

And one core only talks to two other cores at most as to not be talking globally and or having more lock contention

rotund furnace
#

all threads should beable to run on any core

#

(although keeping them on one core might help)

hazy saddle
magic saffron
#

I wouldnt consider sleeping threads when balancing run queues, as you can re-evalate which core the thread runs on when it wakes (last is preferred, but conditions may have changed). You keep each core mostly independent, with some work stealing (if a core runs out of work -> it takes a thread from someone else's queue) and a thread that runs occasionally that scans and balances run queues if needed. If you're worried about too much cross-core traffic you can introduce a hierarchy where cores belong to a family of 4 cores, the neighbouring 3 cores are checked first, then any others (but if we're talking performance, measure first!).

hazy saddle
#

Wouldn’t the scheduler be running on every core

rotund furnace
#

but if you pause a core one cpu

#

it should beable to resume on any cpu with next to no overhead

#

- cache shit

hazy saddle
#

And I assume the handoff is passing over the struct

rotund furnace
#

once a task/interrupt context pushes any gprs that are caller saved, yield will push any callee saved gprs switch stacks restore callee saved and ret

#

that's it

magic saffron
#

the handoff is the same as taking a thread from the local queue, except its a different queue

rotund furnace
#

everything else is choosing which threads execute when

hazy saddle
rotund furnace
#

yeah

#

any core that yields will just get "a new thread"

#

it doesn't matter which one

#

obv this is for the most basic of scheduling but oh well

hazy saddle
hazy saddle
rotund furnace
#

scheduler kinda has two co-equal parts tbh. scheduling a thread to run, and switching to it

hazy saddle
magic saffron
#

demo oriented development lol

hazy saddle
#

Exactly XD

#

What’s why I got bad apple running before VMM

#

💀

rotund furnace
rotund furnace
#

that must of SUCKED

hazy saddle
#

My brain needs to see something working

hazy saddle
rotund furnace
#

the message "syscall! - 0xcafebabe" was enough from me

hazy saddle
#

And I didn’t use dynamic allocation

#

RLE encoding

#

Maybe after SMP and all the other cool stuff I should work on an Intel HD audio driver

#

maybe I can make it play sound effects on kernel panic

#

Btw how are you meant to calibrate the LAPIC timer or other if you don’t have a working PIT on a system

rotund furnace
#

iirc you can use the invariant tsc

#

or some other timer like hpet

#

although iirc hpet also needs calibration

#

idk

magic saffron
#

so

hazy saddle
hazy saddle
rotund furnace
#

damn

magic saffron
hazy saddle
#

I could of sworn I heard about them

#

To get the frequency it used

rotund furnace
#

so like

#

idk

magic saffron
#

on newer intel cpus there is cpuid leaf 0x16 (iirc, maybe its 0x15) to get the lapic timer and tsc frequencies. Other than that you have to calibrate against another timer. On virtual machines you have pv_clock which is excellent. Then you have the ACPI PM timer, HPET and PIT you can use as reference clocks.

rotund furnace
#

this shit is too hard

#

yk what we need

#

a whole new timer that's better then the rest

hazy saddle
#

I was making a joke btw

hazy saddle
magic saffron
#

I mean yeah you could do that, but its pretty unlikely.

hazy saddle
#

Newer Intel CPUs lacking a PIT would have the MSRs so it’s like edge case devices like MacBooks or some shit I think?

magic saffron
#

they're not MSRs, its cpuid

hazy saddle
#

Ahh sorry sorry

magic saffron
#

haha you're alright

#

MSRs are generally writable

#

which would be cool, you tell the timer its frequency.

hazy saddle
#

Would be cool if the x2APIC timer let you do just that since it uses MSRs

#

Read a register for the range it can handle

#

Then write to another for how many times per second to interupt

hazy saddle
#

That’s a working x2apic and timer

mild glacier
hazy saddle
mild glacier
hazy saddle
#

to make sure it was working

mild glacier
#

let's just ignore that ascii art in the bottom right corner 😔
i said this coz it's supposed to be a "let's just ignore the errors" comment

#

how did u get 100+ quadrillion bytes from spawn 💀

hazy saddle
#

@mild glacier my structures were wrong so I read bad memory

#

So it got the wrong address

#

And when it tried to use it

#

Well we all know what happens when you touch non cononaical memory

mild glacier
hazy saddle
#

It’s one of my many random error messages

mild glacier
#

along with what other funni error messages?

hazy saddle
#

Yes

#

All my error messes are random

mild glacier
#

show me what others u have in ur arsenal >:c

hazy saddle
#

It’s open source

mild glacier
#

💀

hazy saddle
#

@mild glacier src/kernel/utils/panic.c

mild glacier
hazy saddle
#

Better credit my ass

#

I spend a good time slacking off making thoes

mild glacier
hazy saddle
#

it is

#

it is licenced

#

under the MIT licence

mild glacier
#

oh ok

hazy saddle
#

btw @rotund furnace i cant find my usb got a moment to test my kernel on a machine with x2apic?

rotund furnace
#

oh and no usb drives

#

so sadly no

hazy saddle
#

damn

#

all good

rotund furnace
#

tbh I'm not even sure the machine I use to test has 2xapic lmao

hazy saddle
#

XD

#

i do get why intel depracated the old one tho

#

the MSR intrface is much nicer

rotund furnace
#

yep

mild glacier
hazy saddle
#

gonna take alot to port the thing

mild glacier
#

but those repetitive printf("(string)\n"); could be replaced with puts("(string)"); plssss

#

it'll save u source code bytes 🙏

hazy saddle
#

have you considered i dont care

#

lol

#

it dosnt matter

#

also i dont have puts implemented

mild glacier
#

lmaooo "I like elephants and god likes elephants" as an error message is an insane reference

hazy saddle
#

wtf?????

#

the PIT is setup the same as before

#

then interupts fail

#

but if i stub the sleep it works

#

nvm my bad

#

i fucked somthin else up

#

okay well closer but not there

#

PS/2 fails when using the PIT

#

but not HPET

#

for some reason

#

the timer works though???

hazy saddle
hollow crater
#

aight u can (should?) go to sleep now lol
i'll see if I can figure out whats going on but I make no promise I will be able to xD

hazy saddle
#

I should sleep

#

Yes

hollow crater
#

g'nightttt!!!

hazy saddle
#

@hollow crater btw did the patch file manage to work and libc build properly?

#

I uhhh

#

Forgot to sleep

hollow crater
hazy saddle
#

Good old GCC pain

#

BTW

#

On some machines

hollow crater
#

i wanted to test it on a clean chroot so here we go

hazy saddle
#

I’ve had it fail

#

And you have to redo it once more for GCC

#

But then it worked

hollow crater
#

oh

hazy saddle
#

Only on a fresh install on my laptop though

#

I’ve ran the script from clean git downloads on my desktop fine one go

#

YMMV

hollow crater
hazy saddle
#

Just a reminder my code is connected together with 14 pounds of duct tape

#

And you got the dev branch right

hollow crater
# hazy saddle YMMV

well in theory this should be the same which's bad
but i have nothing to do anyway so ill do it again if it did

hazy saddle
#

To be fair I also riced the shit out of the laptop too

hollow crater
#

good old win 7 style always wins

hazy saddle
#

It wasn’t too hard either

#

Also I don’t plan to ever update GCC of binutils

#

So you won’t ever have to recompile these

hollow crater
#

well ig i wouldnt have had to do that if i just tested locally 😭
since i already have a cross compiler
but i just thought why not trl

hazy saddle
#

Would my cross compiler even work for yours tho

#

Or vice verca

hollow crater
#

well yes it doesnt seem u had it configured that different from mine
worst case it'd just need extra flags to the makefile here and there

hazy saddle
#

True true

hollow crater
hazy saddle
#

I use clang for kernel

#

GCC for userspace

hollow crater
#

ohhh

#

why that tho

hazy saddle
#

Clang because I use host compiler and clang is better at some things

#

I’ve heard it’s code gen is nicer

#

And I CBA to make an LLVM toolchain for userspace

hazy saddle
#

If I ever get rust in userspace I will do LLVM tho

hollow crater
hollow crater
hazy saddle
#

And I need it to spam emojis all over my readme

#

But like other people might want things in rust

#

Not bad to support it

#

Even though I won’t provide many things natively for it

#

Also @hollow crater my kernel triple faults under GCC

floral kettle
#

smells like UB

hazy saddle
#

Or clang spesific extensions

hollow crater
hazy saddle
#

With the fucking UBSAN

#

Or somthing

hazy saddle
hollow crater
hollow crater
hazy saddle
#

You applied the patch to dev and not master

#

Right

hazy saddle
hollow crater
#

ohhhh

hazy saddle
#

Because dev branch is one ahead where I added that

hollow crater
#

welp lemme fix ts

hazy saddle
#

Because I updated to limine v4

floral kettle
#

also why not clone limine in the makefile nooo

hazy saddle
#

(Protoco(

hollow crater
#

fairfair

hazy saddle
#

I regret that somtimes tho

floral kettle
#

its not tho?

hazy saddle
#

I also get linine binaries from package manager

soft snow
floral kettle
#

I mean like the actual limine binary branch not the protocol

hazy saddle
#

Ahhh

soft snow
#

Lol

hazy saddle
#

Troll

#

True

floral kettle
#

it just tries to use it from the host system /usr/share

hazy saddle
#

I should do that

#

Same for OVMF

rotund furnace
hazy saddle
soft snow
#

I just have a limine folder so I build everything once and then just update it periodically each half year.

hazy saddle
rotund furnace
soft snow
hazy saddle
#

@rotund furnace

floral kettle
# soft snow I just have a limine folder so I build everything once and then just update it p...

I just do this (assuming its an early-stage os project where I don't have a meta package manager I can use to install it and I have a cmake target for running the thing) ```cmake
if(NOT EXISTS "${CMAKE_BINARY_DIR}/limine")
execute_process(
COMMAND git clone https://codeberg.org/Limine/Limine
-b v10.x-binary --depth=1 "${CMAKE_BINARY_DIR}/limine"
)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/iso_root)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PROJECT_BINARY_DIR}/limine/limine-bios.sys
${PROJECT_BINARY_DIR}/limine/limine-bios-cd.bin
${PROJECT_BINARY_DIR}/limine/limine-uefi-cd.bin
${PROJECT_BINARY_DIR}/iso_root
)

execute_process(
    COMMAND git clone https://codeberg.org/Limine/limine-protocol
    --depth=1 "${CMAKE_BINARY_DIR}/limine-protocol"
)

endif()

hazy saddle
#

I think there is another repo for limine and OVMF

rotund furnace
soft snow
#

Its easier.

floral kettle
#

that's also prebuilt tho

#

in the binary branch

hazy saddle
#

I also love when my kernel corrupts OVMF ❤️

soft snow
hazy saddle
#

Make files and bash scripts for everything

#

Who cares if it’s a complete mess

rotund furnace
#

fuck yeah 🔥

#

that's what I'm gonna do while I wait for chariot to get remote compilation

#

after fabricate is done lmao

hazy saddle
#

I do wonder if I should make my own build system for my kernels dependencies where it downloads an alpine CHROOT image downloads everything and builds it

#

@hollow crater is the GCC there get?

#

Yet

soft snow
hazy saddle
#

Compiling my kernel to help find a bug

soft snow
#

I feel like my kernel should be able to compile on every machine just not my machine without big efforts.

hazy saddle
#

GCC tho

#

Oh wait I forgot it already finished didn’t it

#

Sorry

hollow crater
hollow crater
hazy saddle
hollow crater
#

now imma take a look at whats exactly going on

hazy saddle
#

Open a kernel shell

#

Oh that kind of working

#

XD

#

I narrowed it down btw

hollow crater
#

it didnt :P

#

its just stuck there

hazy saddle
#

The interrupt thing isn’t calling the function pointer

#

At all

#

It should be running the generic timer ISR function pointer

#

That different timers plug into

#

But it’s straight up not running

hollow crater
#

mmmmmmm
so neither the pic interrupts nor the pit ones get fired
u sure interrupt handlers are working at all? 💀

hazy saddle
#

Well if that function never calls