#pmOS - microkernel OS for RISC-V, x86, and LoongArch

1 messages · Page 4 of 1

carmine nacelle
#

In what way

#

I'm using old uACPI

hoary moat
#

try to boot into it

#

nothing gets printed

carmine nacelle
#

That may be kernel panic

hoary moat
#

I'd expect logs

carmine nacelle
#

Or broken uACPI

hoary moat
#

But alas

carmine nacelle
#

My kernel doesn't have framebuffer driver

hoary moat
#

In a bit

carmine nacelle
#

It's master uACPI

hoary moat
carmine nacelle
#

You see a bunch of stuff on screen

hoary moat
#

Ok

carmine nacelle
#

Since that's done from userspace

#

Does your PC have PIC?

hoary moat
#

probably emulated

#

pic

carmine nacelle
#

Emulated should be fine

#

Wait

#

PIT*

hoary moat
#

emulated probably

#

still don't see nothin

carmine nacelle
#

Ok

carmine nacelle
#
#

I have the exact same problem

carmine nacelle
#

Ok I think I'm inspired to work on memory objects now...

carmine nacelle
#

What a fun discovery: my pthread_mutex_unblock yielded at all function calls

carmine nacelle
#

And apparently munmap was doing nothing galaxybrain

carmine nacelle
#

A few bug fixes later

#

Everything is an object now

#

And I think I should be able to implement CoW on fork of everything quite trivially

#

But I'm feeling too tired so that's probably for tomorrow

#

(also, uACPI score increased galaxybrain)

twilit talon
#

by how much

left dew
#

should spinlock_lock disable irqs?

#

oh wow ☠️ wrong thread

twilit talon
#

lol

left dew
#

i was reading random threads and coding at the same time and didnt realize im in the pmos thread my bad

carmine nacelle
#

I want to try it on my destop though

twilit talon
#

cool cool

carmine nacelle
#

I want to have AHCI reading though

carmine nacelle
#

After three days of searching, I've found the charger for the asus laptop

#

And it doesn't post

#

Nice

#

Events are working

#

@twilit talon Why would uACPI eval of an even fail with not found?

twilit talon
#

no such event

carmine nacelle
#

Of _Q<some shit>

twilit talon
#

Yeah

carmine nacelle
#

Broken firmware?

twilit talon
#

grep your blob for _Q<IDK>

twilit talon
carmine nacelle
#

There's no new bios

twilit talon
#

all hope is lost then PoroSad

carmine nacelle
twilit talon
#

waybackmachine

#

or fire up your favorite patched linux lmao

#

to see if its some sort of a skill issue

carmine nacelle
#

It reboots when uACPI tries to turn it off btw

twilit talon
#

it or your os meme

#

managarm test ig

carmine nacelle
#

Hmm, it just turned off

twilit talon
#

probably triple faults in some cases

carmine nacelle
#

Why would it

twilit talon
#

managarm test needed

twilit talon
#

in your kapi perhaps

#

or some race

carmine nacelle
#

I have double fault handler

#

And uACPI runs in userspace

twilit talon
#

well we'll never know until u debug it further

carmine nacelle
#

pmOS doesn't tripple fault ultrameme

twilit talon
#

got a dump btw

#

also figure out the event idx

#

and test managarm

carmine nacelle
#

It's refusing to post after turning off 💀

twilit talon
#

lol

#

maybe its just not feeling well

carmine nacelle
#

Could be

twilit talon
#

is it possible the battery is drained faster than its recharged

carmine nacelle
#

Its power button is broken

#

Meybe it turned back on because it got pressed

twilit talon
#

lol

carmine nacelle
#

This laptop has terrible design flaw

left dew
#

it's firmware was written by proper idiots?

carmine nacelle
#

I mean Windows and Linux couldn't turn it off in the past

twilit talon
#

EC generating non existant events a new one

carmine nacelle
#

It would just hang

twilit talon
#

every new laptop uncovers more retardness in firmware

carmine nacelle
#

I'll try to boot it to fedora

#

It has gentoo I think

carmine nacelle
#

But it would take a few days to update with its 1GHz CPU

#

AMD C-60

twilit talon
#

u would think they'd all have similar blobs

carmine nacelle
#

Retarded laptop with retarded cpu

twilit talon
#

but every time i uncover new shit

#

like while with 50 or statements

carmine nacelle
#

With BIOS it worked fine

twilit talon
#

try uefi boot and shutdown with uacpi

#

wonder what the error is

carmine nacelle
carmine nacelle
#

And linux also started to work

#

And I'm not gonna test windows since it would take several hours to install

twilit talon
#

maybe it just needed new enough updates

carmine nacelle
#

Windows 10 that is

twilit talon
#

maybe it requires ec to shutdown

carmine nacelle
#

It's refusing to post again

left dew
#

maybe lack of an ec driver makes it "shut down"

#

but it's not actually shut down

carmine nacelle
#

I do have EC driver

left dew
#

oh

twilit talon
#

and it does shutdown in pmos

left dew
#

but it refuses to post

twilit talon
#

but not on old linuxes apparently?

carmine nacelle
#

And I'm only hobby OS with AMD GPIO driver sunglas

left dew
#

also, when you press the power button after shut down does it light up or is like dead lol

twilit talon
carmine nacelle
#

There's a second button to boot it into the quick boot proprietary linux shit memes

#

Which works

twilit talon
#

wtf is that button

carmine nacelle
#

And it also turns on when I plug the charger in

twilit talon
#

least insane laptop

carmine nacelle
left dew
#

i mean it has a 1ghz amd processor nobody has ever heard of

carmine nacelle
#

And 2000s

twilit talon
#

whats the purpose of that proprietary linux

carmine nacelle
#

quick boot

left dew
#

Wha

twilit talon
#

actual insanity

carmine nacelle
#

There was a series by some yt guy about it

#

I have 2 or 3 laptops which have that

twilit talon
#

i think i remember watching something like that

#

was it michael

carmine nacelle
#

Yes

twilit talon
#

but i dont remember exactly what it was about

carmine nacelle
#

There was some insanity where some laptop manufacturers would even put DVD drive SoCs into laptops

#

And DELL put a second ARM CPU

#

For fast boot

twilit talon
#

wild early 2000s

carmine nacelle
#

But it's usually just some Linux distro

hoary moat
#

cursed

carmine nacelle
#

And a separate button

carmine nacelle
twilit talon
#

Michael MJD

carmine nacelle
#

Not Michael apparently

twilit talon
#

wait i have this exact laptop

#

does it have qb

#

waait it can do that lol??

carmine nacelle
#

He has a whole series on it

#

Different laptop manufacturers did different wild shit

#

Wild and insane

twilit talon
#

ive tested very early uacpi on this laptop

#

worked fine iirc

carmine nacelle
#

No but that's different laptop from mine

twilit talon
#

yeah ik

#

im just surprised i have it

#

this laptop has a very bad uefi impl

#

without a GOP

carmine nacelle
#

Bruh

#

My new laptop has no CMS btw

twilit talon
#

or rather, it has gop but it only supports Blit() and u dont get a framebuffer

carmine nacelle
#

End of an era

twilit talon
#

yeah modern laptops L

carmine nacelle
#

And no S3

twilit talon
#

L

carmine nacelle
#

Ok I'm booting fedora before it completely dies

#

Fedora is def liking it

twilit talon
#

oh well

carmine nacelle
#

It booted

#

ok how do I dump acpi from linux

twilit talon
#

acpidump > dump.txt

carmine nacelle
#

Ok it's trying to install acpica tools

#

And struggling

#

Idk how I managed to install gentoo on it....

#

@twilit talon

twilit talon
#

now lets find out the query number

carmine nacelle
#

What is this

hexed acorn
carmine nacelle
#

I should take dmesg now that I think of it

hexed acorn
#

doesn't aml let you compare strings natively

twilit talon
#
    Method (MCTH, 2, NotSerialized)
    {
        If ((SizeOf (Arg0) < SizeOf (Arg1)))
        {
            Return (Zero)
        }

        Local0 = (SizeOf (Arg0) + One)
        Name (BUF0, Buffer (Local0){})
        Name (BUF1, Buffer (Local0){})
        BUF0 = Arg0
        BUF1 = Arg1
        While (Local0)
        {
            Local0--
            If ((DerefOf (BUF0 [Local0]) != DerefOf (BUF1 [Local0]
                )))
            {
                Return (Zero)
            }
        }

        Return (One)
    }
twilit talon
#

or maybe its firmware dev brain rot

hexed acorn
#

and ig Buffer (BUF) {} works?

#

where BUF is a buffer already

#

oh wait no

#

nvm

carmine nacelle
#

What if I put OpenVMS (whatever that is) on it? ultrameme

twilit talon
#

yeah

hexed acorn
#

Local0 is the size

twilit talon
#

yup

#

string length + null terminator

#

then memcpy the strings

hexed acorn
#

BUF0 = Arg0 is a memcpy of the contents and not a reassignment of BUF0 to the arg?

#

wack

twilit talon
#

in acpica it is a reassignment

#

on windows its a memcpy

carmine nacelle
twilit talon
#

but they clearly do it for windows because Buffer (Local0){} preallocates the buffer with zeroes with correct size

hoary moat
#

technically if AML is insane then doesn't that mean that uACPI is an insane interpreter

#

since it can interpret insane AML

hexed acorn
carmine nacelle
#
[    0.032063] ACPI: SSDT 0x00000000A7CB0A98 00168E (v02 AMD    ALIB     00000001 MSFT 04000000)```?
twilit talon
hexed acorn
#

ALIB = ACPI LIB? meme

carmine nacelle
twilit talon
#

aml is a patchwork of all components

twilit talon
hoary moat
hoary moat
#

and linux also saves it on S3 suspend

twilit talon
carmine nacelle
twilit talon
#

looks normal

carmine nacelle
#

Lol

[   64.734853] watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [(udev-worker):601]
[   64.734980] CPU#0 Utilization every 4s during lockup:
[   64.734987]     #1: 100% system,      0% softirq,      0% hardirq,      0% idle
[   64.734998]     #2: 101% system,      0% softirq,      0% hardirq,      0% idle
[   64.735007]     #3: 100% system,      0% softirq,      0% hardirq,      0% idle
[   64.735015]     #4: 101% system,      0% softirq,      0% hardirq,      0% idle
[   64.735023]     #5: 100% system,      0% softirq,      0% hardirq,      0% idle
twilit talon
#

it has an ECDT even damn

carmine nacelle
#

What's RTCF?

twilit talon
#

read the ... fucking idk?

#

acpica doesnt know

#

it has an oem id of RTCONFIG

#

so some sort of proprietary config

carmine nacelle
#

I think I should shill pmOS there ultrameme

twilit talon
#

yeah

#

some clueless people there

left dew
#

I don't think you can run ACPI in user space. It requires interrupts.

#

what

twilit talon
#

least clueless osdev forums user

left dew
#

oh i just realized you were talking in that thread

twilit talon
#

yeah

left dew
#

but...

8infy wrote:

  • backlight
  • fans, temperatures, etc
    Most of these are documented in chipsets.
#

WHAT

twilit talon
#

lmao

left dew
#

this guy might actually be clinically dumb

twilit talon
#

just hack every manufacturer and steal chipset specs

dense carbon
#

he is notoriously opinionated

twilit talon
#

I don't think you can run ACPI in user space. It requires interrupts.

This kinda invalidates his credibility

dense carbon
#

generally you can't count on interrupts happening in the process that you want to handle them

twilit talon
#

why does this matter?

dense carbon
#

it doesn't

#

i don't know what he thinks you should be doing

twilit talon
#

does he think ill have idt in userspace or something

dense carbon
#

just letting a hpyothetical acpi server install a userland address into the vector table apparently

left dew
#

i think what he thinks

#

is that you'd set the idt entry to like

left dew
#

have a cs with cpl=3

dense carbon
#

which no one would ever do

left dew
#

and have it jump to userspace code

#

but i dont think bro takes into consideration that youcan just signal an event

twilit talon
#

like u have to have a very limited understanding of how any of it works to say something like that

#

or to think that

left dew
#

and dispach something to a userspace process outside the irq

twilit talon
#

just literaly set a pending bit on an eventfd

left dew
#

his brain is stuck in the protected mode single address space era

twilit talon
#

looks like it

left dew
#

i should try and make a microkernel

#

it sounds like fun

dense carbon
left dew
#

even better

#

my approach was kind of naive and dpc-like

#

but you can definitely do something smart and more optimized for a microkernel

twilit talon
#

Solaris engineers should have clearly consulted him

#

Then they would know its impossible

dense carbon
#

what i might imagine if you need to do something very fast, like a multiqueue NIC or disk adapter driver, is to have interrupt threads of your driver server be affine to a CPU, and of a very high priority (so they preempt anything else) and when an interrupt comes in, directly switch into their context

twilit talon
#

Yeah

dense carbon
#

i think in practice people will be making the threads that handle interrupts very high priority anyway, so this may not even be a special case

twilit talon
#

True

left dew
#

the cpu pinning + switching directly into the thread context is smart though

hoary moat
#

this guy is fucking stupid

dense carbon
#

USB resides on PCI, so no idea why ACPI would benefit USB.
what is striking is how he just confidently speaks without the remotest curiosity

hoary moat
left dew
#

least based infy response

hoary moat
#

And ACPI cannot tell you if there is a functional PS/2 keyboard or mouse.
bs

left dew
#

can it tell you if there's a functional ps/2 keyboard/mouse? lol

hoary moat
#

it can tell you if there is one

left dew
#

i think you'd ask the controller about that

dense carbon
left dew
#

it can tell you if there's an i8042 controller and where it is located, no?

#

but that's probably the most acpi will tell you

#

or does it actually tell you more?

hexed acorn
left dew
#

great website

#

it just refuses to load the blog iframe

#

mind stuck in the 90s, website designed for equally old browsers i guess

hoary moat
#

my brain literally started hurting reading him

left dew
#

what

#

first operating system with a built in asperger's test 🔥

dense carbon
# left dew http://svn.rdos.se/rdos/trunk/ - apps - aspie-quiz - ... - kernel

"Based on these evidences, a study in Aspie Quiz asked participants if they could detect somebody's presence without seeing them, which many more neurodiverse people answered 'yes' to. If neurodiverse people can detect presence without using the normal sensory channels, this means they must have some other physical sensory channel. Given the evidences of sensing electromagnetic fields and having psychic abilities, it's assumed that neurodiverse people can use the electromagnetic medium to communicate, and that this might work over large distances."

"The use of Ephedra as an stimulant by Neanderthal might explain the need for Ritalina or Amphetamine in todays individuals with ADHD."

left dew
#

"The use of Ephedra as an stimulant by Neanderthal might explain the need for Ritalina or Amphetamine in todays individuals with ADHD."
that is so dumb

#

who comes up with these

carmine nacelle
carmine nacelle
left dew
#

maybe...

#

i'll take a look but i don't promise anything

#

but at this point i'll probably do anything to not be bored

#

as long as ur project doesn't make me want to off myself just by working on it

#

i.e insane build system or lack of proper maintainer tools (i.e clang-tidy/clang-format)

carmine nacelle
#

Idk I haven't really though about accepting contributions and it's a bit of a mess

carmine nacelle
left dew
#

send repo pls i don't want to look for first message meme

carmine nacelle
#

In vscode

left dew
#

wow gitlab

dense carbon
#

microkernel is an interesting problem space

carmine nacelle
#

It's mirrored on github

#

microkernel is an interesting problem space
and mine is weird

dense carbon
#

to name one thing, i wonder what microkernel would like to do when it comes to zero-copy or as close to zero-copy as possible network i/o?

left dew
#

probably some sort of kernel api to allocate dma memory?

carmine nacelle
#

That was my idea of implementing disk IO

left dew
#

that's mapped into the process + you get to pass it to the device because you get a physical address

carmine nacelle
#

And then you move pages around

#

And it's zero copy disk IO

left dew
#
  • that works nicely with iommu too because the kernel can handle that for you and you just get something you pass to the device anyway
carmine nacelle
#

That's why I want working set before AHCI

carmine nacelle
#

Which would not be swapped out to disk, once I have that

dense carbon
#

i'll let you know if i remember it again

#

but i suppose for implementing (say) sendfile, you can map in chunks of the file VM object and wire those, have some API to get the physical addresses, as to the packet headers you could have a pool of mbuf type structs in wired memory, and deal in those

carmine nacelle
#

I don't know the unix history/right terms 🥶

carmine nacelle
#

Hmm

#

This doesn't feel very microkernely to me (who doesn't know how kernels usually work)

#

Although I guess it could be a good kernel IPC mechanism

#

Yeah

dense carbon
#

in wired memory

carmine nacelle
#

But then how do you do zero copy

#

You're gonna be eating a lot of TLB misses if you move pages around

dense carbon
#

the server would send a scatter-gather list of the physical addresses of the mbufs + the body of the data to the NIC server

carmine nacelle
#

That's fine, but how do you give data to applications

dense carbon
#

that's always been the harder part

#

zero-copy rx is complicated

carmine nacelle
dense carbon
carmine nacelle
#

You could probably try to avoid the network server all together, and do some sorcery to make applications talk to NIC driver processes directly and write straight to their buffers with scatter-gather, with some kernel mechanism making sure userspace doesn't pull the rug out of it

#

That sounds like fun

#

Although the server middle man being a library in the address space of the NIC driver is an implementation detail I guess and is probably not relevant...

hexed acorn
carmine nacelle
#

nice c++ skill issue

carmine nacelle
#

I'm going insane

#

I've added the new CoW thingie, which remaps the R/W pages are read only

#

I've double checked that invlpg gets called

#

info tlb shows it doesn't have write flag

#

and yet it doesn't page fault on call, even though the stack doesn't have the read flag

#

(I'm cloning stack in fork, among other things)

#

But sometimes it seems like it actually does

carmine nacelle
#

What the hell, how does that even happen

#

I'm blaming copilot

carmine nacelle
#
Switching to task 13
syscall_asign_page_table 23 0 3 task 13
Copying page 1000 to 2000 tables 9 12
Copying page 2000 to 4000 tables 9 12
Copying page 3000 to 6000 tables 9 12
Copying page 4000 to 8000 tables 9 12
Copying page 5000 to 9000 tables 9 12
Copying page 13000 to 17000 tables 9 12
Copying page 14000 to 28000 tables 9 12
Copying page 267000 to 2CE000 tables 9 12
Copying page 268000 to 2D0000 tables 9 12
Copying page 26A000 to 2D2000 tables 9 12
Copying page 46A000 to 46A000 tables 9 12
Copying page 7FFFFFFFF000 to 7FFFFFFFF000 tables 9 12
clone page table returned to 13
Switching to task 20
Switching to task 13
Page already allocated table 9
Anonymous page
Page refcount 3
Page 7FFFFFFFFE78 resolved
Switching to task 20
Switching to task 1

Yep it's a nasty tlb skill issue

carmine nacelle
#

Omg

#

I found the bug

#

And it's the dumbest bug I've ever had

#

6 hours of debugging?

#

It's because of return 0

#

Judging by the logs CoW is working perfectly

noble mason
carmine nacelle
#

but that casted to ReturnStr<bool>, which is like broken std::optional

#

So it returned false, which means "page isn't available, block the task"

#

Average C++ skill issue

pearl narwhal
#

mandatory reminder that this wouldn't happen in rust

carmine nacelle
#

Nah I think I have an explicit copy constructor from the result

#

For "convenience"

#

(extra debugging time)

carmine nacelle
pearl narwhal
carmine nacelle
#

Nah

#

Drivers in Rust with it's standard lib

pearl narwhal
#

sure but surely drivers have extra stuff they need

#

like requesting DMA memory

carmine nacelle
#

I have a couple of functions for that

#

Hmm

#

There must be an existing framework for that

#

uAPI rust bindings?

noble mason
# carmine nacelle 6 hours of debugging?

a month ago i had segfault when i was writing a jvm in pure c, after 2 hours of debugging the problem was in ONE symbol (i dont remember exactly, * or +), i understood that when i did a valgrind by tip of chatgpt, and it says what program is "corrupted" pointer, not linked with osdev but yes

carmine nacelle
#

The issue is that nothing was crashing

#

The kernel was just doing its job and quietly blocking the task

#

Like when something crashes at least you know where to look

noble mason
carmine nacelle
#

No, but my IPC blocks the tasks

noble mason
#

oh

carmine nacelle
#

So it's done a lot

noble mason
#

a sick of microkernels

#

many blocks of tasks

carmine nacelle
#

I mean if you do read on linux from pipe, it also blocks

noble mason
#

i know that

pearl narwhal
carmine nacelle
#

asynchronous message queues

#

So like send() and recieve(), the first never blocks and the second blocks if there are no messages

pearl narwhal
#

is it zero copy

carmine nacelle
#

No

#

It's 2 copies and 3 mallocs KEKW

pearl narwhal
#

i really want to get my IPC right

#

i have 0 experience tho

carmine nacelle
#

It's super dumb but I wrote it a year ago and it just always works, and I don't want to touch it

pearl narwhal
#

so it will not be right

pearl narwhal
#

i think that's even more dumb

carmine nacelle
#

Not broken locks again

#

I think I'll just steal x86 implementation

carmine nacelle
#

Cool, RISC-V port is broken for some reason (I'm blaming timers)

carmine nacelle
#

I'm kinda half depressed because I don't know when it broke

#

And what's broken

carmine nacelle
#

Ok I've just realized I've been writing in uACPI thread

#

This is weird

#

I think it's 2 bugs

#

And fork is def broken on risc-v

#

But through exit()debugging (galaxybrain) I've found that the issue is not where I expected it to be

carmine nacelle
#

This is insanity

#

Something is calling exit()

#

But there is a tiny issue

#

There is nothing that could be doing that

#

I need GDB

#

But idk if it's gonna be of help

#

Since it reorders execution of threads

#

The only explanation that I can come up with it tham the thread stacks are somehow mapped with MAP_SHARED

#

and are not being cloned

carmine nacelle
#

After a lot more debugging

#

I think it's the same bug which breaks the framebuffer on x86 on some machines galaxybrain

#

syscall_get_message() turns into exit()

carmine nacelle
#

I pushed the patches to main, I now have anonymous pages I suppose, which do CoW on fork (and now fork doesn't copy any pages)

#

And a random thought at 3:40 am: why have one kernel, when I can have two Thonk
Maybe pmOS needs a sister hybrid or monolithic kernel, which would run the same userspace

carmine nacelle
#

@cyan elk how do I stop lto from assuming if (LIMINE_BASE_REVISION_SUPPORTED == false) is always true?

dense carbon
cyan elk
#

with base revision declared as such: c __attribute__((used, section(".limine_requests"))) static volatile LIMINE_BASE_REVISION(3);

#

i made sure that the Limine boot protocol tolerates LTO well

carmine nacelle
#

__attribute__((used)) fixed it

#

Wow, -O3 + lto assembly is unreadable

#

Not unreadable, but verry different from C++

#

My vector is pagefaulting in a very weird place

#

What the fuck, how does adding assert(tag) on line 646 fix everything?

#

What soer of UB is that?

carmine nacelle
#

This is insanity

#

I have no clue

carmine nacelle
#

Anyway, pmOS kernel now works with -O3 + lto

mellow sleet
#

What did you even do to fix that

carmine nacelle
#

I was overwriting random shit on stack with memcpy KEKW

carmine nacelle
#

I think the time has come to resurrect some old code (PS/2 ultrameme)

#

The implementation was only half-cursed, and I have improved the interrupts memes system, so I'm hoping for the best

carmine nacelle
#

Can anyone explain why my keyboard driver needs threads?

twilit talon
carmine nacelle
#

I'm not yet, but I certainly can

#

I'm trying to resurrect some old code

#

But having a device have 2 interrupts kinda makes it "difficult"

#

Or I can just poll them for now, to make sure the impl has survived

#

Like that driver is from when I didn't have ACPI

carmine nacelle
#

(or I can use PNP I guess)

twilit talon
carmine nacelle
#

How does windows do this (this is a question to myself)

twilit talon
#

windows enumerates all devices in the namespace

#

and binds drivers to them

carmine nacelle
#

I have no such system yet

#

(that's a separate thing)

twilit talon
#

u can do ad-hoc find_devices() rn

carmine nacelle
#

I have to think how to make that work with microkernel

#

And ideally making drivers hot-pluggable

twilit talon
#

managarm publishes discovered stuff to the bus

carmine nacelle
#

Hmm

#

But that has to have all the drivers running

#

Or I can have some sort of discovery server

twilit talon
#

it has a script to check if a driver should be started i think

#

yeah

carmine nacelle
#

And I've been thinking of making some sort of directory which will have driver descriptors or something like that

#

Which can tell which servers correspond to which driver

twilit talon
#

u can just do

uacpi_find_devices("<idk>", spawn_ps2_driver, ...)

for now i guess

carmine nacelle
#

And monitor that they don't crash/etc.

#

I think my design is starting to piece itself together

carmine nacelle
#

Which has uACPI

#

And also FDT parsing on RISC-V

dense carbon
carmine nacelle
#

Which is responsible for device discovery and interrupts management

carmine nacelle
dense carbon
carmine nacelle
#

Oh

#

Idk

#

Why not

#

Besides making it difficult to put stuff in kernel

#

But I guess it's working out with my commitment of having "everything" in userspace

twilit talon
#

how are u going to be dealing with resume from suspend?

#

since that happens in real mode

carmine nacelle
carmine nacelle
#

Don't I just need to jump to long mode, at which point I have userspace?

twilit talon
#

yes but the wake up trampoline is programmed via acpi

#

and then u need acpi to wake up the firmware

#

so ud have to have some tight coupling with devicesd

carmine nacelle
#

I can make kernel return the wakeup vector

twilit talon
#

facs->wake_address = ...

carmine nacelle
#

I already have functions for that

#

So it just wakes up and jumps to a trampoline (?)

#

And then the kernel can just wake other cores

#

And I have userspace

#

The kernel only needs lapic

#

Everything else's userspace responsibility KEKW

twilit talon
#

ud have to somehow tell your drivers that all of the devices are about to suspend and then resume

carmine nacelle
carmine nacelle
#

And coupling to device server

twilit talon
#

anyway that will be a whole load of fun to design

carmine nacelle
#

And kernel events

left dew
#

you probably need to tell every server to suspend its devices and wait for an ack

hoary moat
#

never underestimate the amount of shit you need to do on wake from suspend

left dew
#

suspend purely from userspace sounds like pain

hoary moat
#

?

#

MTTRs?

#

PAT?

#

those stuff would be dead

carmine nacelle
left dew
#

MTRR* meme

carmine nacelle
#

And kernel doesn't even touch it

hoary moat
#

wake from suspend (for the cpu, if you ignore all devices) is the equivalent of starting a new CPU

carmine nacelle
carmine nacelle
#

I've been using multiboot in the past

#

I can bring that stuff up

left dew
#

suspend preserves ram content right?

twilit talon
#

S3 suspend does yeah

hoary moat
twilit talon
#

but literally al hw is reset

carmine nacelle
#

I can also bring back the cursedness where the bootloader program loaded by multiboot2 would start in ring 0, load the kernel, and continue in ring 3

hoary moat
#

except ACPI_NVRAM physical memory might or might not be gone

left dew
#

yeah as long as u communicate that to ur servers u should be fine

carmine nacelle
hoary moat
#

make sure to have an option to disable it

#

apparently some hardware it's not needed

#

because it's not actually said anywhere in the acpi spec

#

but linux says that windows does it

#

so linux does it

carmine nacelle
#

I have exams, so I will probably put everything on hold for a few weeks after finishing the PS/2 meme

#

But I can try implementing S3 suspend

carmine nacelle
#

After that

#

To see how cursed it gets

hoary moat
carmine nacelle
#

Are there microkernels which support S3?

twilit talon
#

restoring PCI BARs is also fun

carmine nacelle
#

That are not Xnu which isn't a microkernel

hoary moat
carmine nacelle
#

I already enumerate PCI there

#

*in userspace

#

Kernel doesn't know and doesn't care about PCI

hoary moat
#

make sure PCI would get restored before restoring devices though

#

you need to have a guarantee on that

carmine nacelle
#

Not kernel's problem chad

carmine nacelle
#

Oh wow PS/2 driver crashed the kernel risc

#

userspace crash kernel bad

left dew
#

kernel debugger is a very nice thing to have

carmine nacelle
#

I had it but removed it

#

It was bzt's meme

#

My kernel doesn't need a debugger

#

(except when it does)

#

Didn't support risc-v

carmine nacelle
#

Btw

#

Are there good examples of resolving symbols in stack traces?

#

I've tried to do that in the past with libunwind

#

But it didn't work

left dew
#

you can the simple way by getting a list of symbols and if addr >= start && addr < end then print that symbol's name

carmine nacelle
#

I've seen that Nyaux had it...

left dew
#

that is what nyaux does

#

just parse the kernel's symbol table

manic girder
#

I don't know about good, but I made a copy of any function symbols and you can do a search on them later

left dew
#

of course that won't handle inlined call sites and such but it's good enough for debug builds

manic girder
#

I found you can get rid of about half of the symbol table in a debut build, which saved some memory, fwiw

carmine nacelle
#

Thonk I think this is getting out of hand

left dew
#

why all of those are getting passed "init" cmdline

carmine nacelle
#

So they are loaded by the bootstrap server

#

on boot

manic girder
#

I mean, afaik there's no limit on the number of modules

carmine nacelle
#

Yeah, but I might need to write some script which generates limine configs

#

Or finally write a disk driver

#

I mean I have AHCI

left dew
#

maybe you should have an init server that loads all the servers from disk? :^)

carmine nacelle
#

Maybe I need to give up on working set

#

Before disk

left dew
#

then you can list them in a text file instead of the limine config

carmine nacelle
#

Yeah

manic girder
#

Is there any reason you don't roll evrrything into an initrd and pass that to the boostrap program?

carmine nacelle
#

I haven't implemented it

#

I can do that

manic girder
#

Something like tar is as simple as it gets if youre concerned about complexity

carmine nacelle
#

I have ustar parser thingy which I planned to use as ramfs

manic girder
#

Yeah nice

carmine nacelle
#

But everything's unfinished

#

It parses archives fine

#

But I need to work on the filesystem aspect of it

#

Also my VFS is horrendous

#

I think I need to rewrite it

#

In C++

#

Or Go

#

Because why not have VFS in Go

#

(though I need to get it working first)

#

(it was only half-working)

#

Like I would create 10 goroutines with printf and only five of them would print something and it would stop working KEKW

#

Too many things to do nooo

#

Too ambitious of a project

#

How with 50k LoC I still don't have a shell or disk driver?

carmine nacelle
#

Written with chatgpt KEKW

carmine nacelle
#

Like if I map /, then /dev, then /proc and then remap root, what happens to those

#

(which would get handled by the devices server and POSIX process server)

left dew
#

linux "layers" the mounts tmpfs on /home/hacker/test1 type tmpfs (rw,relatime) devtmpfs on /home/hacker/test1/test2 type devtmpfs (rw,relatime,size=16360856k,nr_inodes=4090214,mode=755) sysfs on /home/hacker/test1 type sysfs (rw,relatime)

that's me mounting tmpfs on ~/test1, creating a directory called test2 inside and mounting devtmpfs there and then mounting sysfs on ~/test1

#

the two previous mounts are still there but you can't access them because sysfs is mounted on top of it

#
hacker@raptor:~$ sudo umount test1
hacker@raptor:~$ ls test1
hi  test2```
#

unmounting the sysfs mounted there allows me to access them again

#

i was not aware that this is how it works actually, i might want to think hard about how i want to write my vfs to support that 😅

carmine nacelle
#

Fun, I think O3 + lto might have surfaced another bug

#

Or not

#

I have no idea what's going on

#

Wth, how does it get to %rax=0xFFFF800000019170 (which is right) and %r15=0xFFFFFFFF (wtf) and doesn't fail the assert?

#

cpu is u32 and cpus.size() is size_t, so u64

left dew
#

what if cpu_affinity is 1

#

so you do cpu = cpu_affnity - 1

#

and then cpu - 1

carmine nacelle
#

bruh

#

I'm dumb

left dew
#

what is it?

carmine nacelle
#

cpu - 1

left dew
#

oh

#

lmaoo

carmine nacelle
#

should be cpu

#

My cpu_affinity is if (cpu_affinity == 0) then any cpu else cpu with id = affinity - 1

left dew
#

interesting

#

i would expect affnity to be a bitmask

#

of cpus a thread can be scheduled on

carmine nacelle
#

Yeah

#

The name of the variable is wrong

#

It's the CPU that the task is bound to

#

Which decides if it goes to global run queues or cpu-local ones

#

(My scheduler is a bit of a mess)

left dew
#

affinity is kind of the right name for that

#

it absolutely makes sense

carmine nacelle
#

I want to remove the global queues eventually

#

"It probably creates a lot of lock contentions"

#

(because I haven't measured if it does, and everything is slow anyway so it doesn't matter)

#

Also bitmasks are kinda somewhat problematic because of what if you boot on machine with > 64 cores

#

There needs to be some mechanism for allocating them dynamically

left dew
#

just have enough to store the affinity for all cpus

#

yeah

carmine nacelle
#

And I haven't bothered to implement that

#

And with global run queues bitmasks kinda make no sense

#

so

#

a mess

left dew
#

with global run queue(s) bitmasks make a lot of sense

carmine nacelle
#

Why is it failing? nooo (talking to myself)

left dew
#

cpus need to know whether they can take the task or not

carmine nacelle
#

But what if you have a lot of tasks and a lot of cpus

left dew
#

unless you meant per-cpu queues

#

uh yeah i am not the best person to reason about this :^)

carmine nacelle
#

maybe I think too much about everything

carmine nacelle
#

I thought I commented that out ok

#

Cool, Makefiles skill issue

#

How do I make QEMU issue SPCR? roundnthonk

left dew
#

what the heck is an SPCR

carmine nacelle
#

SPCR ACPI table

#

Which tells operating systems to shit the logs to serial controller

left dew
#

interesting

carmine nacelle
#

It's a thing on RISC-V

#

But doing grep, it seems that it's only for ARM and RISC-V

twilit talon
#

u can make it append any table using -acpitable

carmine nacelle
#

I want some standard mechanism for my OS to decide that it can send logs to serial

#

I can just discover COM ports I guess...

twilit talon
#

com ports should be exposed via both fdt and acpi

carmine nacelle
#

But what if that has a COM mouse connected to it

#

It's not gonna print logs KEKW

#

risc-v, arch and loongarch have SPCR to tell OS that com is usable for logs

#

there must be something for servers on x86

carmine nacelle
#

(probably besides running AML)

twilit talon
mellow sleet
carmine nacelle
#

There should be some probing mechanism...

#

What am I getting myself into... https://en.wikibooks.org/wiki/Serial_Programming

This book explains different aspects of serial data communication. Serial data communications is the foundation for most forms of data communications used with modern computing devices. The focus of the articles in this book will be around the implementation of RS-232 (aka RS-232C, aka V.24, aka EIA-232D, etc.) based serial data communication an...

#

I'll try asking ChatGPT more nicely

#

Do mice still use the same protocol as serial ones???

left dew
#

on x86 you've got ps2 and usb

carmine nacelle
#

Do I even need serial mouse?

left dew
#

probably not lol

carmine nacelle
#

My (B550) PC has a serial port ultrameme

#

Ouch, no

left dew
#

lmaoo

#

u can get a usb mouse for 10th of that price

carmine nacelle
#

But I'm sure some people still have DOS boxes so they should still be made

#

Anyway

#

I almost have PS/2

#

Just need to sprinkle pthread_mutex_lock around the driver

#

And it doesn't work

hoary moat
#

astral curse

mellow sleet
#

Astral curse

carmine nacelle
#

I was missing fflush

#

Now time to add interrupts

#

Surprisingly, the driver has survived almost all of the changes

#

That I did around it

hoary moat
#

ps2 driver
fflush

carmine nacelle
#

Why not

#

ps2 driver
pthreads

twilit talon
carmine nacelle
carmine nacelle
#

(I'll add ACPI after interrupts)

#

Does ACPI tell me IO ports, interrupts and so on?

hoary moat
#

yes

#

in resources

carmine nacelle
#

Are there PCI PS/2 controllers?

hoary moat
#

no

carmine nacelle
#

Can there be more than 1 controller?

twilit talon
#

Yes

carmine nacelle
#

i8042 that is

twilit talon
#

Its an unaswerable question

#

I can make a vm that does have 10 of them

#

Are there real world examples? Who knows

carmine nacelle
#

Ok, then I'll support multiple

carmine nacelle
#

I don't want to assume anything

twilit talon
#

Add support for multiple i8042 devices to qemu

#

Ez

#

Can be done in 30 minutes

carmine nacelle
#

Which PNP is PS/2?

twilit talon
#

Idr, but you can take a look at managarm

#

It does ps2 via acpi

carmine nacelle
#

They're using mbus

#

Input event codes?

#

I need to implement that

carmine nacelle
#

Fun, it's not AMD GPIO bug

carmine nacelle
#

Astral curse nooo

#

My interrupts are refusing to work

twilit talon
twilit talon
carmine nacelle
#

Yes my PS/2 driver just doesn't work

#

For no reason

#

I'm suspecting it could be the same bug that's haunting RISC-V port

#

Like how does this happen

#

My IPC can't be broken

#

I know what's happeningn

#

I think

twilit talon
#

inb4 u have some stupid memcpy bug again

carmine nacelle
#

I don't think so

#

Although everything is possible

#

I think I have an explanation how this could happen

carmine nacelle
#

pause_task cancells the blocking syscalls with -EINTR and that's probably why it can't get message

#

Another great question is, how does AHCId work?

#

Galaxybrain kernel interface

#

And fork is broken because I'm not casting resut to int???

#

Anyway

#

I don't get it

#

How does it return 0 yet fail?

#

Something's trolling me

#

I have another theory

#

Nope

#

But it is the same bug

#

On RISC-V, the return value which is the same register as syscall number gets set to 0 and it calls syscall_exit after fork

#

On x86 it returns success

#

(which is 0)

#

They must be related

#

fork uses syscall_pause and syscall_resume

#

interrupts use the same mechanism

#

Yep, it never executes the syscall and returns success

#

pmOS curse : something messing with saved registers

carmine nacelle
#

What the hell

#

Here's the bug

#

Now, what's setting %rax to 0?

#

I thonk I found it

#

(line 1604)

#

Now it just pagefaults

carmine nacelle
#

Well, the driver has been resurrected I guess

left dew
#

on real hw?

carmine nacelle
#

I guess

#

It doesn't use ACPI though

#

And only reads scancodes

left dew
#

i can try on my older machine which im unsure it does ps2 emulation

carmine nacelle
#

Like I don't have a shell

left dew
#

will it print stuff tho?

carmine nacelle
#

Yeah

left dew
#

does it do uefi?

#

the iso

#

ah fuck it will test it

carmine nacelle
#

it's limine

carmine nacelle
left dew
#

not much interesting stuff happened

#

ill comment out ahci

carmine nacelle
#

I think it's not recieving interrupts

#

yeah...

carmine nacelle
left dew
#

nope i just edited limine config

carmine nacelle
#

is there a way to mask interrupts in lapic?

#

I guess if the kernel complains about no handler for interrupt, it is being lost

#

I think I never enable interrupts...

vale hazel
#

eeeeetick

manic girder
#

And yeah that way you can use a bitmask and not worry about the number of cpus

hoary moat
#

because realistically, who is booting obos, let alone booting obos on a cpu with >128 cpus

manic girder
#

128 cores should be enough for anyone

carmine nacelle
#

4 cores was enough 10 years ago

#

Idk, of course it's impractical considering the other parts of the kernel, but still

#

"why limit myself"

carmine nacelle
#

this is something new...

#

It booted once just fine

#

And this became consistent

#

(and this laptop was refusing to turn on)

#

Insane firmware?

#

@twilit talon it crashed in uacpi_namespace_node_resolve in while (node) { if (node->name.id == name.id) something something

#
 222490: 44 09 c6                         orl    %r8d, %esi
  222493: 40 0f b6 ff                      movzbl    %dil, %edi
  222497: 01 fe                            addl    %edi, %esi
  222499: 81 c6 00 00 00 5f                addl    $0x5f000000, %esi       # imm = 0x5F000000
;         if (bytes_left != 0 && single_nameseg)
  22249f: a8 01                            testb    $0x1, %al
  2224a1: 0f b6 c0                         movzbl    %al, %eax
  2224a4: 0f 45 c1                         cmovnel    %ecx, %eax
;     if (parent == UACPI_NULL)
  2224a7: 4d 85 e4                         testq    %r12, %r12
  2224aa: 4c 0f 44 e2                      cmoveq    %rdx, %r12
  2224ae: 4d 8b 64 24 20                   movq    0x20(%r12), %r12
;     while (node) {
  2224b3: 4d 85 e4                         testq    %r12, %r12
  2224b6: 74 63                            je    0x22251b <uacpi_namespace_node_resolve+0x2ab>
  2224b8: 0f 1f 84 00 00 00 00 00          nopl    (%rax,%rax)
;         if (node->name.id == name.id)
  2224c0: 41 39 74 24 04                   cmpl    %esi, 0x4(%r12)
  2224c5: 74 19                            je    0x2224e0 <uacpi_namespace_node_resolve+0x270>
  2224c7: 4d 8b 64 24 28                   movq    0x28(%r12), %r12
;     while (node) {
  2224cc: 4d 85 e4                         testq    %r12, %r12
  2224cf: 75 ef                            jne    0x2224c0 <uacpi_namespace_node_resolve+0x250>
  2224d1: eb 48                            jmp    0x22251b <uacpi_namespace_node_resolve+0x2ab>
  2224d3: 66 66 66 66 2e 0f 1f 84 00 00 00 00 00           nopw    %cs:(%rax,%rax)
;     while (bytes_left != 0) {
  2224e0: 4d 85 ff                         testq    %r15, %r15
  2224e3: 0f 85 dc fe ff ff                jne    0x2223c5 <uacpi_namespace_node_resolve+0x155>
  2224e9: e9 75 fe ff ff                   jmp    0x222363 <uacpi_namespace_node_resolve+0xf3>
hoary moat
#

don't forget to send the asl blob

#

*aml

carmine nacelle
#

(leaving this here since I want to finish with PS/2 first)

#

I have sent it

#

before

#

I give up

#

I don't know who's galaxybrain but my laptop replies with 0xfa and does not report the layout that is used

#

I think I've sunk too much time into it, I'll just commit everything and fix that later

#

Something fishy's going on with interrupts though

#

It worked on 2/3 of my laptops

twilit talon
twilit talon
#

Anyways send a dump and a dmesg that Linux produces if you have that

carmine nacelle
#

I don't

carmine nacelle
twilit talon
#

yeah

carmine nacelle
twilit talon
#

@carmine nacelle btw any way u can enable the debug log level at least

#

to see where exactly this happens

carmine nacelle
#

uacpi_context_set_log_level?

twilit talon
#

yeah

twilit talon
# carmine nacelle I think it's this
❯ /mnt/d/uacpi/tests/runner/build-linux-64bits/test-runner dsdt.dat -x ssdt1.dat ssdt2.dat --log-level info
[uACPI][INFO] RSDP 0x00007FFF3EFBC000 00000024 v02 (uOEMID)
[uACPI][INFO] XSDT 0x0000606000000320 0000003C v02 (_ASUS_ uTESTTBL)
[uACPI][INFO] DSDT 0x0000630000000400 0000F116 v02 (_ASUS_ Notebook)
[uACPI][INFO] FACP 0x00006120000004C0 00000114 v06 (uOEMID uTESTTBL)
[uACPI][INFO] SSDT 0x0000622000000100 0000168E v02 (AMD    ALIB    )
[uACPI][INFO] SSDT 0x0000618000000080 0000030C v01 (AMD    POWERNOW)
[uACPI][INFO] FACS 0x0000606000000380 00000040
WARN: remapping physical 0x00000000BEBEBEBE with size 4096
[uACPI][INFO] successfully loaded 3 AML blobs, 2738 ops in 23ms (avg 118951/s)
got a GPE
WARN: remapping physical 0x00000000BEBEBEBE with size 128
[uACPI][INFO] namespace initialization done in 158ms: 90 devices, 1 thermal zones
[uACPI][ERROR] unable to lookup named object 'ECFL' within (or above) scope '\_SB_.PCI0.SBRG.WEC_._REG': not found
[uACPI][ERROR] aborting method invocation due to previous error: AML referenced an undefined object
[uACPI][ERROR]     #0 in \_SB_.PCI0.SBRG.WEC_._REG()
[uACPI][ERROR] error during _REG execution for (EmbeddedControl) operation region \_SB_.PCI0.SBRG.WEC_.ECOR: AML referenced an undefined o...

works in userspace as always

#

but this doesnt mean much ofc

carmine nacelle
#

Idk maybe it's my bug

twilit talon
#

not the first bug that can only manifest in a real kernel

#

lets see debug logs

carmine nacelle
#

But this laptop wasn't turning on, then it did turn on, booted once fine, and then had this error

twilit talon
#

2738 ops its pretty tiny too

carmine nacelle
#

Judging by the logs it has crashed here

twilit talon
#

which line?

carmine nacelle
#

83 I guess?

#

Or later

#

Anyway

#

I'm trying it

twilit talon
#

if its 83 should be easy to debug then

carmine nacelle
#

Also, it's unsing my sprintf implementation

#

The laptop is refusing to turn on again 😦

twilit talon
carmine nacelle
#

It could be anywhere tbh

#

I think it's in line 573 of namespace.c

#

btw

twilit talon
#

its probably line 83 in your init_from_ecdt right

carmine nacelle
#

could be

#

or could be after that

twilit talon
#

can u test?

carmine nacelle
#

the laptop is not turning on

twilit talon
#

lmao

twilit talon
#

Yeah no I dont see how this could be a uacpi bug, I've looked pretty much everywhere I could

#

So im going to wait for you to dump more logs if you can turn it on

twilit talon
carmine nacelle
#

uacpi_table_find_next_with_same_signature?

carmine nacelle
twilit talon
carmine nacelle
#

Oh

#

bruh

#

yeah

#

Also uacpi_namespace_node_find might leak?

twilit talon
#

nodes are permanent

carmine nacelle
twilit talon
#

reminds me of the ultra ps2 driver

#

unless thats where u stole that from

#

look at repeat_until loops with for (;;);

#

this shit was bulletproof

#

and it worked on a whole bunch of laptops with multiple ps2 mice

#

aka the touchpad & the joystick thing

carmine nacelle
carmine nacelle
twilit talon
#

no idea

carmine nacelle
#

It looks like you were never doing that in your code

#

Idk maybe I should remove it as well

#

Synaptics touchpad driver is cool

twilit talon
carmine nacelle
#

Maybe I need usb...

#

Do I just need XHCI and OHCI?

left dew
#

xhci is enough for anything modern-ish

#

xhci does both usb 3 and 2

carmine nacelle
#

I have laptops without USB 3

left dew
#

then you will need ehci

#

ochi is usb 1

#

or actually idk

carmine nacelle
#

but ohci also handles that?

left dew
#

there are 4 controllers

#

ohci, uhci, ehci and xhci

#

i think ohci/uhci are usb 1

#

i know ehci is usb 2

#

also, just because you don't see a blue usb 3 port that might not mean there isn't an xhci controller, but it would be kinda weird

#

still a good idea to lspci and see if there's an xhci controller

carmine nacelle
#

It's a low-end netbook from 2012

left dew
#

are u 100% positive it doesn't do xhci?

#

in that case, you want to implement ehci too

carmine nacelle
#

It's refusing to boot so kinda difficult to check sadmeme

left dew
#

ah that one meme

#

is that the only machine without xhci?

carmine nacelle
#

ok it booted

left dew
#

ah you said laptops, nvm

carmine nacelle
#

I have another laptop

#

And my old PC, which needed drivers for USB 3

#

It was a high-end motherboard

left dew
carmine nacelle
#

uACPI debug build first meme

#

@twilit talon last thing it printed

#

Considering that the keyboard doesn't work, it should have died

#

It's so slow Gnome is struggling with it

twilit talon
#

also what are these random numbers in log

carmine nacelle
#

This is what it has @left dew

carmine nacelle
#

It's from uACPI trl

carmine nacelle
carmine nacelle
carmine nacelle
left dew
#

but yeah do ehci, it far less insane than ohci

#

im not sure if these two interact somehow like xhci does with ehci tho

#

you'll have to read up on that

carmine nacelle
left dew
#

it's not a very nice experience to write a driver for that iirc

#

idk the details, i have never tried obviously lol

hoary moat
#

at least if your printf is pre-built

left dew
#

but ehci is easier iirc

#

and of course xhci is the easiest, it's kinda similar to nvme

carmine nacelle
#

And my write functions don't terminate, so I think my sprintf also doesn't

carmine nacelle
carmine nacelle
#

Ok I'm seriously thinking about rewriting my VFS in C++

#

With coroutines ultrameme

dense carbon
carmine nacelle
#

?

dense carbon
#

pray what would the coroutines be for

carmine nacelle
#

To resolve the tree

dense carbon
#

why?

carmine nacelle
#

It's a "vfs cache"

#

I have a central server which is in charge of mountpoints and whatnot