#pmOS - microkernel OS for RISC-V, x86, and LoongArch
1 messages · Page 4 of 1
I'd expect logs
Or broken uACPI
But alas
In a bit
It's master uACPI
What is the expected behavior when it boot successful
You see a bunch of stuff on screen
Ok
Ok
Hello. I purchased the $1500 HP SPECTRE X360 13-AE013DX in April 2018 for college. It is less than four years later, and the laptop will not turn on or charge. The power light flashes for a second, then immediately goes off. When I plug a charger into the USB C ports, the charging light illuminates....
I have the exact same problem
Ok I think I'm inspired to work on memory objects now...
What a fun discovery: my pthread_mutex_unblock yielded at all function calls
And apparently munmap was doing nothing 
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
)
by how much
lol
i was reading random threads and coding at the same time and didnt realize im in the pmos thread my bad
It's gotten to 800k+, after I ran it once
I want to try it on my destop though
cool cool
I want to have AHCI reading though
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?
no such event
Of _Q<some shit>
Yeah
Broken firmware?
grep your blob for _Q<IDK>
probably outdated bios generating garbage
There's no new bios
all hope is lost then 
waybackmachine
or fire up your favorite patched linux lmao
to see if its some sort of a skill issue
It reboots when uACPI tries to turn it off btw
Hmm, it just turned off
probably triple faults in some cases
Why would it
managarm test needed
well we'll never know until u debug it further
pmOS doesn't tripple fault 
It's refusing to post after turning off 💀
Could be
is it possible the battery is drained faster than its recharged
lol
This laptop has terrible design flaw
it's firmware was written by proper idiots?
I mean Windows and Linux couldn't turn it off in the past
EC generating non existant events a new one
It would just hang
every new laptop uncovers more retardness in firmware
uacpi W
u would think they'd all have similar blobs
Retarded laptop with retarded cpu
When booting with UEFI
With BIOS it worked fine
No it did shutdown
And linux also started to work
And I'm not gonna test windows since it would take several hours to install
maybe it just needed new enough updates
Windows 10 that is
maybe it requires ec to shutdown
It's refusing to post again
.
maybe lack of an ec driver makes it "shut down"
but it's not actually shut down
I do have EC driver
oh
and it does shutdown in pmos
but it refuses to post
but not on old linuxes apparently?
And I'm only hobby OS with AMD GPIO driver 
also, when you press the power button after shut down does it light up or is like dead lol
apparently thats the power button being broken?
There's a second button to boot it into the quick boot proprietary linux shit memes
Which works
wtf is that button
And it also turns on when I plug the charger in
least insane laptop
It's very typical for 2010s laptops
i mean it has a 1ghz amd processor nobody has ever heard of
And 2000s
whats the purpose of that proprietary linux
quick boot
Wha
actual insanity
There was a series by some yt guy about it
I have 2 or 3 laptops which have that
Yes
but i dont remember exactly what it was about
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
wild early 2000s
But it's usually just some Linux distro
cursed
And a separate button
what's his chanel name?
Michael MJD
HP took a look at all the other Quick Start products and said "oh, we can do worse." They did.
Support me on Patreon: https://www.patreon.com/cathoderaydude
Tip me: https://ko-fi.com/cathoderaydude
Chapters:
00:00 Quickweb recap
04:02 Feature 1: QuickLook
09:15 QuickLook under the hood
15:30 What's an EFI application?
29:15 QuickLook in summa...
Not Michael apparently
He has a whole series on it
Different laptop manufacturers did different wild shit
Wild and insane
No but that's different laptop from mine
yeah ik
im just surprised i have it
this laptop has a very bad uefi impl
without a GOP
or rather, it has gop but it only supports Blit() and u dont get a framebuffer
End of an era
yeah modern laptops L
And no S3
L
oh well
acpidump > dump.txt
Ok it's trying to install acpica tools
And struggling
Idk how I managed to install gentoo on it....
@twilit talon
What is this
is MCTH a custom string comparison function? 
I should take dmesg now that I think of it
match() yeah
doesn't aml let you compare strings natively
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)
}
well NT fails if lhs type != rhs type, maybe they wanted to compare strings against buffers or something
or maybe its firmware dev brain rot
What if I put OpenVMS (whatever that is) on it? 
yeah
Local0 is the size
BUF0 = Arg0 is a memcpy of the contents and not a reassignment of BUF0 to the arg?
wack
but they clearly do it for windows because Buffer (Local0){} preallocates the buffer with zeroes with correct size
technically if AML is insane then doesn't that mean that uACPI is an insane interpreter
since it can interpret insane AML
i guess this behavior would make sense in a strongly typed language
[ 0.032063] ACPI: SSDT 0x00000000A7CB0A98 00168E (v02 AMD ALIB 00000001 MSFT 04000000)```?
@hoary moat btw this has tons of NVS regions
what
Two vendors?
ALIB = ACPI LIB? 
What's that
well some are shipped by bios, some are shipped by firmware, some are gpu, etc
aml is a patchwork of all components
yeah probably
ACPI non volatile regions
basically they should be conserved when going to S4
and linux also saves it on S3 suspend
memory that must be preserved during suspend for firmware state
what's your verdict? 
looks normal
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
it has an ECDT even damn
What's RTCF?
read the ... fucking idk?
acpica doesnt know
it has an oem id of RTCONFIG
so some sort of proprietary config
Wth is this discussion? https://forum.osdev.org/viewtopic.php?t=57109
I think I should shill pmOS there 
least clueless osdev forums user
oh i just realized you were talking in that thread
yeah
but...
8infy wrote:
- backlight
- fans, temperatures, etc
Most of these are documented in chipsets.
WHAT
lmao
this guy might actually be clinically dumb
just hack every manufacturer and steal chipset specs
he is notoriously opinionated
he invented his own dubious "neanderthal theory" which you can read at https://rdos.net/eng/
RDOS operating system, homo sapiens and Neanderthal hybridization cause of Asperger, ADHD and autism, x86 emulator, anti psychiatry
I don't think you can run ACPI in user space. It requires interrupts.
This kinda invalidates his credibility
his reply is odd
Maybe possible, but you don't want to do it. For one, the interrupt might not even happen in the process where ACPI is mapped.
generally you can't count on interrupts happening in the process that you want to handle them
why does this matter?
does he think ill have idt in userspace or something
just letting a hpyothetical acpi server install a userland address into the vector table apparently
lol
have a cs with cpl=3
which no one would ever do
and have it jump to userspace code
but i dont think bro takes into consideration that youcan just signal an event
like u have to have a very limited understanding of how any of it works to say something like that
or to think that
and dispach something to a userspace process outside the irq
just literaly set a pending bit on an eventfd
his brain is stuck in the protected mode single address space era
looks like it
good god, solaris is already doing routing of interrupts into foreign threads in 1991 - an interrupt handler on solaris, if it tries to block, the state will be saved and automagically copied over to a thread waiting to take over
even better
my approach was kind of naive and dpc-like
but you can definitely do something smart and more optimized for a microkernel
Lmao
Solaris engineers should have clearly consulted him
Then they would know its impossible
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
Yeah
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
True
the cpu pinning + switching directly into the thread context is smart though
this guy is fucking stupid
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
least based infy response
And ACPI cannot tell you if there is a functional PS/2 keyboard or mouse.
bs
can it tell you if there's a functional ps/2 keyboard/mouse? lol
it can tell you if there is one
i think you'd ask the controller about that
here i was thinking that that's why it has the bloody nodes for both
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?
[...] cause of Asperger, ADHD and autism, x86 emulator [...]
i wonder what's the cause of x86 emulator
great website
it just refuses to load the blog iframe
mind stuck in the 90s, website designed for equally old browsers i guess
my brain literally started hurting reading him
http://svn.rdos.se/rdos/trunk/
- apps
- aspie-quiz
- ...
- kernel
what
first operating system with a built in asperger's test 🔥
"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."
"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
Lol
Maybe pmOS needs contributors 
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)
Idk I haven't really though about accepting contributions and it's a bit of a mess
I have clang-format, but it's half broken
send repo pls i don't want to look for first message 
wow gitlab
microkernel is an interesting problem space
It's mirrored on github
microkernel is an interesting problem space
and mine is weird
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?
probably some sort of kernel api to allocate dma memory?
Just make network cards write to memory objects?
That was my idea of implementing disk IO
that's mapped into the process + you get to pass it to the device because you get a physical address
- 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
That's why I want working set before AHCI
Yeah my memory objects take DMA flag, which allocates contiguous memory from pmm
Which would not be swapped out to disk, once I have that
there's all kinds of scattery gathery stuff that the nic driver will want to deal in, i had something in mind which seemed challenging but i've completely forgotten it
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
I don't know the unix history/right terms 🥶
they're described well at https://man.freebsd.org/cgi/man.cgi?mbuf(9)
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
well i would be expecting pool of mbufs would be kept in the networking stack server
in wired memory
But then how do you do zero copy
You're gonna be eating a lot of TLB misses if you move pages around
the server would send a scatter-gather list of the physical addresses of the mbufs + the body of the data to the NIC server
That's fine, but how do you give data to applications
Alternatively you can just use shared memory
yes, some kind of ring buffer with a doorbell probably ideal way to communicate to the NIC driver what you want to send
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...
ig in managarm you could have a memory object with the data to send, send the handle to it over ipc, then have the nic dma straight to it via scatter-gather
nice c++ skill issue
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




Copying page 7FFFFFFFF000 to 7FFFFFFFF000 tables 9 13
invlpg 7FFF801FF000

What the hell, how does that even happen
I'm blaming copilot
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
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
skull
Which is right
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
mandatory reminder that this wouldn't happen in rust
Nah I think I have an explicit copy constructor from the result
For "convenience"
(extra debugging time)
Also I have been thinking about using Rust for drivers and whatnot
would be cool to have a higher level driver framework for drivers in rust
I have a couple of functions for that
Hmm
There must be an existing framework for that
uAPI rust bindings?
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
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
if it quietly blocked the task then try to add the scream into speakers when its blocks the task
No, but my IPC blocks the tasks
oh
So it's done a lot
I mean if you do read on linux from pipe, it also blocks
i know that
is your IPC super complicated or?
asynchronous message queues
So like send() and recieve(), the first never blocks and the second blocks if there are no messages
is it zero copy
It's super dumb but I wrote it a year ago and it just always works, and I don't want to touch it
so it will not be right
well my first buddy allocator used a VecDeque as a freelist
i think that's even more dumb
Cool, RISC-V port is broken for some reason (I'm blaming timers)
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 (
) I've found that the issue is not where I expected it to be
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
After a lot more debugging
I think it's the same bug which breaks the framebuffer on x86 on some machines 
syscall_get_message() turns into exit()
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 
Maybe pmOS needs a sister hybrid or monolithic kernel, which would run the same userspace
@cyan elk how do I stop lto from assuming if (LIMINE_BASE_REVISION_SUPPORTED == false) is always true?
does it doing this even with volatile?
this does not happen to me
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
__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?
Anyway, pmOS kernel now works with -O3 + lto
What did you even do to fix that
I think the time has come to resurrect some old code (PS/2
)
The implementation was only half-cursed, and I have improved the interrupts memes system, so I'm hoping for the best
Can anyone explain why my keyboard driver needs threads?
you will be using acpi to discover ps/2 devices right
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
I just check the bit in FADT, right?
(or I can use PNP I guess)
no
How does windows do this (this is a question to myself)
u can do ad-hoc find_devices() rn
I have to think how to make that work with microkernel
And ideally making drivers hot-pluggable
managarm publishes discovered stuff to the bus
Hmm
But that has to have all the drivers running
Or I can have some sort of discovery server
uDevD maybe
(Or I can integrate that into the devices server)
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
u can just do
uacpi_find_devices("<idk>", spawn_ps2_driver, ...)
for now i guess
And with microkernel, as I do with AHCI driver which fork()s itself on all controller it finds, I can just launch server as needed (and kill them)
And monitor that they don't crash/etc.
I think my design is starting to piece itself together
I have "devicesd"
Which has uACPI
And also FDT parsing on RISC-V
that must be fun
Which is responsible for device discovery and interrupts management
@manic girder wrote a great library for it, which makes it easy and relatively nice
i mean in general dealing with ACPI and an FDT in userland not kerneland
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
how are u going to be dealing with resume from suspend?
since that happens in real mode
Like HPET
?
Don't I just need to jump to long mode, at which point I have userspace?
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
How is that done?
I can make kernel return the wakeup vector
facs->wake_address = ...
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 
ud have to somehow tell your drivers that all of the devices are about to suspend and then resume
Idk userspace has to figure that out
IPC?
And coupling to device server
anyway that will be a whole load of fun to design
And kernel events
you probably need to tell every server to suspend its devices and wait for an ack
never underestimate the amount of shit you need to do on wake from suspend
suspend purely from userspace sounds like pain
how about I/O APIC
?
MTTRs?
PAT?
those stuff would be dead
I manage that in userspace
MTRR* 
And kernel doesn't even touch it
wake from suspend (for the cpu, if you ignore all devices) is the equivalent of starting a new CPU
I could also do that from userspace
Yeah
I've been using multiboot in the past
I can bring that stuff up
suspend preserves ram content right?
S3 suspend does yeah
S3 yes
but literally al hw is reset
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
except ACPI_NVRAM physical memory might or might not be gone
yeah as long as u communicate that to ur servers u should be fine
I can also preserve that from userspace
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
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
this is my architecture specific wake code
Are there microkernels which support S3?
restoring PCI BARs is also fun
That are not Xnu which isn't a microkernel
https://github.com/OBOS-dev/obos/blob/master/src/oboskrnl/power/suspend.c#L45-L107
this is my platform independent wake code
Can also be done from userspace
I already enumerate PCI there
*in userspace
Kernel doesn't know and doesn't care about PCI
make sure PCI would get restored before restoring devices though
you need to have a guarantee on that
kernel debugger is a very nice thing to have
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
Astral curse
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
you can the simple way by getting a list of symbols and if addr >= start && addr < end then print that symbol's name
I've seen that Nyaux had it...
I don't know about good, but I made a copy of any function symbols and you can do a search on them later
of course that won't handle inlined call sites and such but it's good enough for debug builds
I found you can get rid of about half of the symbol table in a debut build, which saved some memory, fwiw
I think this is getting out of hand
why all of those are getting passed "init" cmdline
I mean, afaik there's no limit on the number of modules
Yeah, but I might need to write some script which generates limine configs
Or finally write a disk driver
I mean I have AHCI
maybe you should have an init server that loads all the servers from disk? :^)
then you can list them in a text file instead of the limine config
Yeah
Is there any reason you don't roll evrrything into an initrd and pass that to the boostrap program?
Something like tar is as simple as it gets if youre concerned about complexity
I have ustar parser thingy which I planned to use as ramfs
Yeah nice
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 
Too many things to do 
Too ambitious of a project
How with 50k LoC I still don't have a shell or disk driver?
Some very carcinogenic C
Written with chatgpt 
The reason why I didn't implement initrd yet is because I'm not very clear on the dynamics of remapping /
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)
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 😅
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
what is it?
cpu - 1
should be cpu
My cpu_affinity is if (cpu_affinity == 0) then any cpu else cpu with id = affinity - 1
interesting
i would expect affnity to be a bitmask
of cpus a thread can be scheduled on
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)
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
And I haven't bothered to implement that
And with global run queues bitmasks kinda make no sense
so
a mess
with global run queue(s) bitmasks make a lot of sense
Why is it failing?
(talking to myself)
cpus need to know whether they can take the task or not
But what if you have a lot of tasks and a lot of cpus
unless you meant per-cpu queues
uh yeah i am not the best person to reason about this :^)
maybe I think too much about everything
Ugh
I thought I commented that out 
Cool, Makefiles skill issue
How do I make QEMU issue SPCR? 
what the heck is an SPCR
SPCR ACPI table
Which tells operating systems to shit the logs to serial controller
interesting
It's a thing on RISC-V
But doing grep, it seems that it's only for ARM and RISC-V
u can make it append any table using -acpitable
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...
com ports should be exposed via both fdt and acpi
But what if that has a COM mouse connected to it
It's not gonna print logs 
risc-v, arch and loongarch have SPCR to tell OS that com is usable for logs
there must be something for servers on x86
Fdt?
Although maybe they did that because there wasn't other standard mechanism for discovering serial ports with ACPI on RISC-V 
(probably besides running AML)
flat device trees
O
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???
on x86 you've got ps2 and usb
Do I even need serial mouse?
probably not lol
But I'm sure some people still have DOS boxes so they should still be made
Lol
Anyway
I almost have PS/2
Just need to sprinkle pthread_mutex_lock around the driver

And it doesn't work
astral curse
Astral curse
I was missing fflush
Now time to add interrupts
Surprisingly, the driver has survived almost all of the changes
That I did around it
ps2 driver
fflush
How do u discover it?
only a tiny bit overengineered
I assume it exists unconditionally 
(I'll add ACPI after interrupts)
Does ACPI tell me IO ports, interrupts and so on?
Are there PCI PS/2 controllers?
no
Can there be more than 1 controller?
Yes
i8042 that is
Its an unaswerable question
I can make a vm that does have 10 of them
Are there real world examples? Who knows
Ok, then I'll support multiple
How do I do that? 
I don't want to assume anything
Fun, it's not AMD GPIO bug
what is it
astral curse is ps2 never working
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
inb4 u have some stupid memcpy bug again
I don't think so
Although everything is possible
I think I have an explanation how this could happen
It probably is
pause_task cancells the blocking syscalls with -EINTR and that's probably why it can't get message
(if someone thought my fork was overengineered, my interrupts management is even better) https://gitlab.com/mishakov/pmos/-/blob/main/devicesd/generic/interrupts.c?ref_type=heads#L8
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
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
on real hw?
i can try on my older machine which im unsure it does ps2 emulation
Like I don't have a shell
will it print stuff tho?
Yeah
it's limine
I'm testing on my laptop
nope i just edited limine config
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...
eeeeetick
I solved this by grouping cores together into 'clusters', 4 cores in my case. Each cluster has a queue that replaces what the global queue might do.
And yeah that way you can use a bitmask and not worry about the number of cpus
I thought about that so I decided to use a __uint128_t
because realistically, who is booting obos, let alone booting obos on a cpu with >128 cpus
128 cores should be enough for anyone
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"
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>
(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
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
Needs a dump, this doesnt tell me much tbh
Also u say it booted once, that kinda gives me a hint that it might be a bug on your side with uninitialized memory somewhere perhaps?
Anyways send a dump and a dmesg that Linux produces if you have that
I don't
You mean AML dump?
yeah
I think it's this
@carmine nacelle btw any way u can enable the debug log level at least
to see where exactly this happens
uacpi_context_set_log_level?
yeah
❯ /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
Idk maybe it's my bug
But this laptop wasn't turning on, then it did turn on, booted once fine, and then had this error
2738 ops its pretty tiny too
Judging by the logs it has crashed here
which line?
if its 83 should be easy to debug then
Also, it's unsing my sprintf implementation
The laptop is refusing to turn on again 😦
ive tested line 83 with your blob and it behaves correctly
yeah this is the line i tested and it works fine
its probably line 83 in your init_from_ecdt right
can u test?
the laptop is not turning on
lmao
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
btw u never unref tables so u leak all the mappings
uacpi_table_find_next_with_same_signature?
I though that should unref it
yes but u do early returns
nodes are permanent
lol
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
linux
Are there keyboards which don't support querying current scancode?
My laptop, for some reason responds with two acks (for 2 bytes) of 0xF0 0x00 but doesn't follow that up with the current scancode
Do you know anything about it?
no idea
It looks like you were never doing that in your code
Idk maybe I should remove it as well
Synaptics touchpad driver is cool
yeah it was pretty interesting to write
I have laptops without USB 3
but ohci also handles that?
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
It's a low-end netbook from 2012
It's refusing to boot so kinda difficult to check 
ok it booted
ah you said laptops, nvm
I have another laptop
And my old PC, which needed drivers for USB 3
It was a high-end motherboard
lspci of that would be nice
uACPI debug build first 
@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
wheres the gpf
also what are these random numbers in log
This is what it has @left dew
I see OHCI and EHCI...
It's also possible that the kernel had run out of memory 
I have a theory that my sprintf doesn't terminate strings
damn that's shit
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
What's insane about it?
it's not a very nice experience to write a driver for that iirc
idk the details, i have never tried obviously lol
make sure if it's snprintf, you add one to len to include the nul-terminator
at least if your printf is pre-built
I'm using my own printf 
And my write functions don't terminate, so I think my sprintf also doesn't
I like to live dangerously
Nice
Perhaps
pray what for
?
pray what would the coroutines be for
To resolve the tree
why?


