#uACPI - a portable and easy-to-integrate ACPI implementation
1 messages · Page 33 of 1
Probably lol
windowing needs async, though
Not really, you can just block (in case of send)
Or busy poll your nic or whatever (in case of recv)
Well, sure, it will still work but it's also not hard to write it in a way that doesn't cause a ton of retransmission during normal operation
hmm maybe
A not entirely stupid minimal send would: block until window size > 0 -> send packet -> wait for ack
A minimal receive would receive packets up to an internal buffer size, then announce window = 0 and ack
That way you still don't need to deal with multiple in flight packets but you also won't randomly cause retransmission despite no packet loss
that's still better than TFTP though
and probably even simpler
TFTP works Fine™️ on lans with very low packet loss, so it's probably fine for quite a lot of things
even on lans its slow af tho
nah its equivalent to base TFTP
except you have room to expand to better impls
Gonna drop 30 commits when I merge this PR soon, which will mark the 1.0 release
not a single api break which is nice

im likely not gonna change much here besides adding a few new AML tests, so if you're free to test right now (or some time soon) that would be nice
i've changed quite a lot of interpreter logic
I can test now, but whether I should is a different question (I'm at school)
nah I'm on my laptop
ah lol
nah just test when you're back home with all of your pcs
im not in a rush anyway
these are the most dangerous potentially
but new special field handling might break something too

nice
x2
how tf did u test it in school
on a personal laptop
what is it supposed to do?
what, waking from suspend?
after
print it woke from suspend and return to bash
in qemu?
yes
try revertng and seeing if its an obos regression instead 
because qemu doesnt have a _WAK and i didnt change any other logic
lucky you infy
wonder where it works
u mean hangs
obos suspend regression #99999
except I haven't changed any acpi code 
maybe your on_wake hook for some driver hangs

wtf
it was never calling into OBOS_Suspend
I was trying to fix a bug with receiving from the uart driver
so I made the powerctl command use getchar instead of my workaround
so I could test it
@fiery turtle yeah suspend worked
letsgo
at school? 💀
infy we have a problem
it hangs
with new uacpi
I tested on the exact same commit of obos with old uacpi, it didn't hang
we're gonna need some triple fault debugging
**before suspend
huh
it hangs before suspend
so does it hang before or after
it hangs during kernel init, so before suspend
that should be easy to printf at least
yeah
☠️
or it didn't hang in the first place and I misread my logs
it never hung
that's a compiler error 
that doesn't handle timeouts properly
Obos has never handled timeouts properly lol
Timeouts on locks are CRINGE
Do not respect them out of spite for the firmware devs
yeah they are
Infiltrate microsoft and change the acpi driver to not handle them
either 0 or infinite are the only respectable ones
Send a patch to linux to not handle them
Resist the oppression firmware devs do against os devs
Send a patch to netbsd
timeouts suck. they are annoying to implement and they should ideally never be hit.
but it is better to timeout than to deadlock forever.
btw... is it guaranteed that AML will release mutexes in the same thread that acquires them? because my mutexes make the following assumption:
* - The same task that holds a lock must unlock it.
yes
they're force released by uacpi upon method exit if aml forgets to do it
hm i should probably make sure i handle 0 timeout properly at some point
for me, a timeout of zero is just "optimistically try to acquire the mutex. if it fails, don't try again."
it's like the easiest part of a mutex implementation
it is I just don't remember if I bothered lmao
it is literally just:
/**
* Attempt fast mutex lock. Returns true on success, otherwise writes the value
* found in @mutex->owner_and_lock into *@expected.
*/
static inline bool
mutex_lock_fastpath (struct mutex *mutex, struct task *self, unsigned long *expected)
{
*expected = 0;
unsigned long desired = (unsigned long) self;
return atomic_cmpxchg_acqrel_acq (&mutex->owner_and_lock, expected, desired);
}
// ... later in the same file
/**
* Lock @mutex. Common part.
*/
static errno_t
mutex_lock_common (struct mutex *mutex, usecs_t timeout_us, bool interruptible)
{
struct task *self = get_current_task ();
unsigned int task_state = interruptible ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE;
unsigned long expected;
if (mutex_lock_fastpath (mutex, self, &expected))
return ESUCCESS;
if (!timeout_us)
return EAGAIN;
// ... invoke mutex slowpath
}
and my mutexes are overcomplicated
yeah i know, i just again dont remember if i literally ever bothered when i was putting together my wait code
Unrelated, but Im trying to make serenityos devs listen https://github.com/SerenityOS/serenity/pull/25653#issuecomment-2597828496
This is an attempt at reviving IdanHo's PR #19556 , which has gone stale.
Original description:
This includes a couple of bug-fixes, and the pretty big pre-requisite of an AML parser, but w...
Doubt anyone is gonna care tho
also cringe recursive parser 
I would expect no less from serenity
lol
they will say to PR the code or shut up 
Lmfao
i know of an easy to use ACPI implementation they can adopt
They're fully nih I think
bold to claim you're nih when you're copying *NIX/posix
well at least its more nih than using existing code
Lol
i suppose
I've seen far more unique projects here though
yeah there def are
yeah well, serenity is just a bunch of people who have no idea how to osdev trying to osdev
most people are people who don't know how to osdev trying to osdev,
what matters is how much you're willing to learn from your mistakes 
everyone starts somewhere
But I don't have a lot of respect for serenity at this point
Thats the thing, they aren't trying to learn I guess, because every driver is like this acpi thing, only works on qemu, makes bogus assumptions, half unimplmemnted and barely tested
Yeah they've got some issues
sounds like some of the drivers in my kernel
I should go and fix them, particularly xhci because I tried fixing it at some point but then I just ended up making it worse
though to be fair I don't even have that many for actual real hardware, rtl8139/8169 (which works as long as the phy is properly handled by the fw), gicv3, spmi (incomplete and not properly hooked to anything), hda, xhci (like I said its kinda broken), usb hid (might be slightly broken idk) and usb rndis
yeah
my xhci driver also mostly worked before I tried fixing it, the reason why I started to mess with it was an old mouse from like 2002 (3y older than me lol) generating a transaction error when getting the first 8 bytes of the device desc after first sending set addr with the bit set that prevents it from reaching the device (I tried with different packet sizes too like 8 and 64 but neither helped)
what's odd is they don't seem to extend it in any significant way either
it's good to do posix since it's the open standard for operating systems but that doesn't mean that all innovations should be rejected
they support bsd stuff like W^X and unveil etc 
none of the great stuff like capsicum, kqueue, jails though
w^x is pretty good
they do jails iirc
also they disallow syscalls from everywhere but libc
it's trifling
for sure
you are apparently right so i accept i went too far in my condemnation
idk how good or faithful their jail implementation is though
they also have a "syscall region" thing, which apparently comes from mach (but i might be wrong)
meaning any syscall made from outside that memory range won't work
it's an openbsdism
Did u know that actually all end users need to contribute code when they want a feature? Even when they arent a programmer, too!!!!
that is fair though lol
i wouldn't want random people coming in and harassing me to add feature x or y
if u want it then do it urself
if it want it too then i might invest some time into it
If a project is important enough, then this simply isnt acceptable
boo hoo
In serentity's case it isnt that big, so meh
its fair to say "hey would you be interested on implementing this yourself?", saying "either implement this or fuck off" is very heavy handed
working together
with serenity i think it rubs people the wrong way because of their various claims like "Modern kernel"
This would also be acceptable !!!
yeah probably
im not a big fan of the hostility
moreover there is a bit of a denial of the complexities of engineering big systems that's inherent to the logic of this response
especially since its supposed to be semi professional
but like i dont blame them either
for example, would serenityos say that someone should submit a PR to turn it into a microkernel?
that is my personal approach, say when I would be able to do it, and offer fixing it yourself if I feel like the issuer could do it, as an option
the same goes for a lot of other changes, there's no point pretending there's just blocks of code and you throw them into a PR and that's a change made
Ya, as long as people arent telling nonprogrammers to fuck off when they ask for smth as integral as accessibility features
god, that one's a bit worrying
though i accept that free software in general is a place where social responsibility is very lacking and that's visible in how little there is in the way of accessibility
in particular ever since Sun went away and since the advent of wayland, accessibility in the whole GNOME stack has gradually withered away to now being effectively unusable
probably bad
Recently there's been a big opportunity for me and my siblings to influence a company and its actions, so maybe eventually I'll be able to make the next sun, in terms of enforcing accessibility
I hope one day I'm big
So many ways I'd like to improve computing
One last thing I decided to do before 1.0 is GAS caching, more specifically so that
- the entire GAS is mapped before its used as opposed to per-access-mapping
- for FADT registers, everything is pre-mapped at init time
uacpi_status uacpi_map_gas(const struct acpi_gas *gas, struct mapped_gas *out_mapped)
{
uacpi_status ret;
uacpi_u8 access_bit_width;
uacpi_size total_width;
ret = gas_validate(gas, &access_bit_width, &total_width);
if (ret != UACPI_STATUS_OK)
return ret;
out_mapped->access_bit_width = access_bit_width;
out_mapped->total_bit_width = total_width;
out_mapped->bit_offset = gas->register_bit_offset;
if (gas->address_space_id == UACPI_ADDRESS_SPACE_SYSTEM_MEMORY) {
out_mapped->mapping = uacpi_kernel_map(gas->address, total_width / 8);
if (uacpi_unlikely(out_mapped->mapping == UACPI_NULL))
return UACPI_STATUS_MAPPING_FAILED;
out_mapped->read = uacpi_system_memory_read;
out_mapped->write = uacpi_system_memory_write;
out_mapped->unmap = uacpi_kernel_unmap;
} else { // IO, validated by gas_validate above
ret = uacpi_kernel_io_map(gas->address, total_width / 8, &out_mapped->mapping);
if (uacpi_unlikely_error(ret))
return ret;
out_mapped->read = uacpi_kernel_io_read;
out_mapped->write = uacpi_kernel_io_write;
out_mapped->unmap = uacpi_kernel_io_unmap;
}
return UACPI_STATUS_OK;
}
I might make this public API as well tbh
/*
* Map a GAS for faster access in the future. The handle returned via
* 'out_mapped' must be freed & unmapped using uacpi_unmap_gas() when
* no longer needed.
*/
uacpi_status uacpi_map_gas(const struct acpi_gas *gas, uacpi_mapped_gas **out_mapped);
void uacpi_unmap_gas(uacpi_mapped_gas *);
/*
* Same as uacpi_gas_{read,write} but operates on a pre-mapped handle for faster
* access and/or ability to use in critical sections/irq contexts.
*/
uacpi_status uacpi_gas_read_mapped(const uacpi_mapped_gas *gas, uacpi_u64 *value);
uacpi_status uacpi_gas_write_mapped(const uacpi_mapped_gas *gas, uacpi_u64 value);
Something like this
what is a GAS?
thanks to this, qualcomm engineers were able to put the reset register in EmbeddedControl address space 💀
its one register
oh its one region in an address space
i mean, that does make sense
resetting requires talking to the EC
no smm on arm
yeah
it could also be part of 8042 emulation on x86
EL3 
since at least on cros_ec it's routed to the EC as well
EL3 is actually stronger than SMM :^)
Smm also has page tables
page tables for the target system that is
But with el3 you have per core timers and I think even interrupt redirection
You do?
Nono I meant you do as in, i didn't know el3 had those
Doesn't only el2 have those?
bruh the 1.0 PR is getting huge
at 33 commits right now
but those are all very imporant changes id like to have before release
you could make it a 0.99 PR for people to test, and when that gives a satisfactory result, you do the actual 1.0 PR.
ill have people test before merging ofc
i love release candidates
mandatory astral test
is the kernel api going to change?
testing would be funni too
indeed
how old is your commit for it to only be at 300k 😭
very
commit e0f1fd3e031d6749472776c9a4b306aa3b8edb12 (origin/rewrite, origin/HEAD, rewrite)
Author: Matheus <[email protected]>
Date: Mon Oct 28 16:24:43 2024 -0300
tsc: fix it being broken when max base leaf < 0x15
dang
matheusuky
matheu suky
sukie bapswent confirmed???
i won't stop yapping until everyone here accesses pci ecam via eax/ax/al only
Least insane amd requirement
what thats a requirement? even tho ecam is mmio?
Yup
that's it
how do they even think they can enforce it when the cpu core only sees a memory write
char cpu_vendor[13] = {0};
memset(cpu_vendor, 0, 13);
__cpuid__(0, 0, nullptr, (uint32_t*)&cpu_vendor[0],(uint32_t*)&cpu_vendor[8], (uint32_t*)&cpu_vendor[4]);
if (memcmp(cpu_vendor, "AuthenticAMD", 12))
{
OBOS_Log("Fuck you AMD, OBOS is just gonna sit here and triple fault\n");
return;
}```

at least on modern CPUs it's not enforced
nah just map ecam as wb and flush the cache line after each write
but it's a good idea to follow the rule anyway
why is it a thing anyway
who knows
like what is the technical reasoning for it
from the perspective of the cpu core its a memory read/write, the core itself cant know what is behind it, so it doesnt make sense
though to be fair if its only like one old cpu then not like it really matters
what if just to tease them I use edx
yeah the rule doesn't make sense to me either but it exists and persists to this day so
not like it has a big impact
I highly doubt the codegen impact of requiring eax instead of any register is significant compared to the MMIO access itself
or just don't care about it, its going to work just fine on the majority of cpus I am sure
valid
I implemented it anyways because it's not difficult at all
but at least on zen 3 it works perfectly fine if not using eax
just report to the user that his cpu is faulty
I bet the technical reasoning is stupid
Maybe some SMM emulation expects it to behave that way
maybe
TLDR always use legacy pci io and you're golden 
whats a pcie 
speaking of amd requirements I'm still mad that high level page tables can't have the global bit set on amd (its ignored on intel)
why does it matter
recursive page tables can't be global mappings
can't you set the global bit only for the last pml?
i.e. PTE if you're only using 4KiB pages
recursive page table<
that wouldnt work
it's recursive so the high level tables are also low level depending on how you get to them
oh I thought you just have a recursive function to get the last PML
but the page tables themselves are recursive
solution to all paging problems: don't use recursive page tables
why would someone use them?
they seem to complicate stuff rather than simplifying it
I like how this thread becomes home to a lot of discussions related to anything but uACPI
lmao yeah
it costs one top level page entry and you get access to any page structure for a virtual address without having to do traversal
so.. the benefit is you don't traverse the page tables?
not manually anyway yeah
I can get any of the page tables for a virtual address with just some bit math
and I can get any page table for a virtual address with just some function calls and some bit shifts
what's the deal
it isn't really a big deal either way
does save having to manually map all the page tables but that's not a huge deal
it's more of a hack than anything, which seems harder to implement than a "normal" VMM
or maybe not but still, it's a hack and imo it should not be relied on
I guess this is subjective
shrug it's technically a hack but it fails out of the standard so it can be relied on. either way it's subjective
but when you have issues like this maybe one would just do normal page tables instead lol
idk its kinda whatever
the benefit is that you get to access any of the paging structures currently in use without having to map all physical memory
mostly useful on 32 bit platforms where an hhdm is infeasible
yeah
i think windows still uses it and linux might but for them its probably a holdover more than anything
we need to convince upstream to switch to uacpi
Linux doesn't have recursive page tables
But they are neat, I used them to embed the buddy allocators metadata directly in the page table entries of the direct map
And if you want to iterate the page table for whatever reason it's also very convenient since you don't have to do a tree like iterations but it's just a for loop
they're still carrying the requirement around in various manuals for modern cpus
i found it in some document for zen3/4 iirc
it's probably just ^C^V at this point without much thinking though?
I use temporary mappings in my kernel
No issues with recursive mappings, and no issues with 32 bit platforms
there are slight issues with performance though
those can be mostly mitigated ig
but still not as good as recursive or hhdm
But those also potentially cause a lot of page walks
how are there 32k messages in here
I have a new motto proposal btw
uACPI, the shitty kernel microbenchmark for garbage homebrew kernels
Lol
damn uACPI thread is going to go past obos' message count soon
I need to lock in and get shit done
can't compete with nyaux anyways
fr
tf
too many one word messages
the early days of the nyaux thread were different
lmao
Fun fact u didnt care about:
❯ grep -rh "SCI Interrupt :" | sort --unique
[02Eh 0046 2] SCI Interrupt : 0009
the SCI IRQ is always 9 (on literally all 500 blobs that I have)
(well okay its set to 0 on hw-reduced blobs)
that's actually interesting
Finally got around to fixing the ACPICA bug i was talking about: https://github.com/acpica/acpica/pull/998
Almost done with these sorts of tests for opregion types
One last (the hardest) left for GenericSerialBus
and on the test runner side
How many features/feature completeness could a os achieve with only table and aml support without ec and non mmio/pci gas support?
non mmio/pci gas is very very rare, like i've only seen it on arm
as for no EC, u can basically do most things as well, some of the more advanced aml stuff might not work, like reading battery stats for example
so with no ec you lose out on advanced laptop things then?
advanced laptop things like the power button :^)
yeah
or well, on modern amd laptops the power button doesnt even use the ec
for AMD u literally need an AMD GPIO driver as well lol
well and a lot of aml blobs unconditionally assume ec is supported if u report modern windows
but if u play around with uacpi's OSI settings u can report old windows
just report that you're hp-ux or something 
yeah only servers check for HP-UX lmfao
i think my old laptop checks for it as well
damn
idk if it does anything with that information other than treating it the same as some version of windows tho
neat
One day I'll dump the AML from my Itanium machines, I bet that'll be fun to look around in
definitely
Just gonna ask rene and some others for the AML dumps, idk why i never thought to ask them
is rene the guy from t2
Ya
I would be surprised if someone in their server didnt have some old stuff, i can def ask around
much appreciated
I actually figured out what should be the first Compaq laptop with ACPI, but I haven't bought one yet.
Compaq is known for the amount of quirks it has in the kernel so should be insane
btw @fiery turtle https://damn99.com/en/2021-03-13-com0com/ signed com0com
Thanks!
np
is there a source for this? cant find anything about it to reference
amd bios and kernel developer guide
thanks
from the family 15h one
"Preliminary Processor Programming Reference (PPR) for AMD Family 19h Model 11h, Revision B1 Processors Volume 1 of 6" section 2.1.7.1 is the latest document that still mentions it
for zen 3/3+/4
where did you find it?
okay "Processor Programming Reference (PPR) Vol 1 for AMD Family 1Ah Model 02h C1 - 57238 Rev 0.24 - Sep 29, 2024" also contains that
in section 2.1.8.1
why does uacpi have the io_read/io_write be multiplexed calls
isnt it a dirtier approach all around than having separate functions for separate sizes? you have to pass bigger integers than necessary, do switches for the byte size values, handle bad cases...
why is it not io_read8, io_read16, and io_read32
Well, uacpi handles bad cases probably
its left for the kernel to do it
What do you even mean by bad cases?
because a lot of kernels already have their own similar functions that do the switch, u can just redirect the call to those
any value that isnt valid, like, anything above 4 for x86 platforms
also, less apis to implement == better
Just return invalid value?
Invalid argument
Not like that's impossible to do
yeah but why do you have to do that at all is the point here
Meh I think it's fine
ACPICA gives u raw bit size that u must round up to next byte boundary
so theres that

lmfao what
yea..
but yeah i agree that uacpi should have split 8/16/32
this is a really weird justification when it comes with these drawbacks, and I must say ive seen no kernel implement their port IO like this, because honestly, its moronic
Most sane ACPICA kernel api
yeah and it pesimizes codegen for no good reason
I can see this as an argument, but you are paying a lot for it
if you want to do it inside uacpi that is your deal
dont pass that debt to the kernel
uacpi doesnt know the size its going to read or write ahead of time
so its the same exact code
just different place
or AML fields
static safety is still better though
it doesnt affect performance
OBOS_EXPORT obos_status DrvS_WriteIOSpaceBar(pci_bar* bar, uint16_t offset, uint32_t val, uint8_t byte_width);
OBOS_EXPORT obos_status DrvS_ReadIOSpaceBar(pci_bar* bar, uint16_t offset, uint32_t *val, uint8_t byte_width);```

yeah
if uacpi has to do the switch, that is their issue, why do you have to dirty the kernel API so you dont have to do it
its such a weird approach
also i am not gonna say anything but i don't think that "ACPICA does it like that" should be much of a justification for doing things similarily :^)
nah i was giving an example of how u can make this api even worse lol
yeah i'm just saying
ACPICA makes you kill all your children so uACPI claiming only your firstborn is great design
but yeah i agree overall that its cleaner
wtf why cringe
Felt like it
shkwve straight up does not have io bars at all lol, and its fine
R8169
Needs IO space bars
sorry i dont have any nics at the moment
Just some ethernet controller
the closest i have to a NIC is usb
hey i have usb and u dont so im right and ur wrong, checkmate!
as a matter of fact if it were up to me i'd get rid of the io_map/io_unmap APIs entirely and just have the io read/write 8/16/32 and that's it, for x86, since that's basically the only platform that needs it, and to hell with following the ACPI spec to the T
though i should probably fix it
its nonsensical on not x86 anyway
yeah
thats straight up not how it works
microkernels and stuff tho
iopl them and be done with it
it doesn't, it also has memory bar
True true
anyway ill make a vote about splitting them i think
managarm has it in kernelmode
pmos
pmOS
thats what he does atm lol
or lazily attempt obtaining permissions for it
IF you have port io emulation THEN it's tied to the pci controller and not the entire chip anyway
#polls message
idk it just seems a bit overcomplicated but i maybe just haven't thought it through
i mean honestly, apart from the microkernel thing i'd be okay with uacpi straight up inlining its own asm for it
^
e.g. reactos has one api for mapping phys memory and io ports
so it would have to leak a handle
or have internal cache
I think that goes against the uacpi philosophy™️
or just not use the api for mapping io ports
or just read/write without bothering with mapping
well in reactos u have to map
or map all ports at startup and who cares that its broken
dont see ```
IF ((OS = REACTOS) and (IO address not mapped))
THEN (* ReactOS says you have to map sorry *)
#GP(0);
FI;
lol
anyway korona had some very good arguments for why we should keep the map api
i was gonna remove it entirely
oh really?
it was a bit more than that
Microkernels aren't even real anyway
like why have map for memory and pci, but not io, which is technically also on every other arch
why make it special just because its not needed on x86
Also is uacpi 1.0.0 soon
i think its a good argument
io is only on x86 tho
io exists on anything that has pci
aml can still use it tho
Device (PCI0)
{
OperationRegion(..., SystemIO, ...)
}
AML could probably do anything
return error(fuck you shitty vendor)
lol
like linux does have io support for aml compiled in for arm
explicitly
so im assuming thats for a reason
Wassit do
Elixir Cross Referencer - source code of Linux v6.13-rc3: drivers/acpi/osl.c
which is enabled by
another question, for the virtual memory map functions of uacpi, what caching do you guys prefer
uncachable?
nope
general purpose write back?
that will kill your perf
idk im asking
I use hhdm
on x86 u use hhdm
Soooooooooo
ah yes the hhdm caching
very specific
the one set up by firmware in MTRRs
well ok u use MTRR which are set correctly
Yes very
no e820 outside of x86
the efi memory map does not have any entry that tells you "use caching mode X"
I just got told to not do UC
and put a fence and cache flush before and after it (riscv)
no, dont do what pitust tells u jesus lol
Elixir Cross Referencer - source code of Linux v6.13-rc3: arch/arm64/kernel/acpi.c
no u dont
normal memory is mapped as normal memory
honestly. just map it nGnRnE and be done with it
that will kill your perf tho
how much actual perf do you lose by that?
aml takes very little time
well if u poll battery every X ms that will accumulate
where X=probably like a second?
no idea tbh
and a poll is maybe a couple writes
and anyway arm ngnrne does not apply to ram, only devices
how does it work on stuff like risc-v?
Probably just a memory bar
the pci controller has a memory mapped window for it
pio on non x86 is just MMIO with an offset
so on x86 you have mtrrs
it does map normal ram as PAGE_KERNEL_RO tho, everything else gets ngnrne, if linux can do it u can too
linux is boring and too good for me
im mapping it ngnrne and you cant stop me
also linux is like a pretty good os
I use UC..?
damn
Idk it works as normal
I map framebuffer as UC 
lmfao
i mean aml is trusted code lol
Because my phys map function just maps everything as UC
meanwhile me with SCTLR.C=0:
I need to change that, but I have other things to do
true
this week
pmOS doesn't use hhdm 




hhdm is for the weak
yeah and those with performance concerns too i guess
the difference is in a couple of page walks
wait, nGnRnE applies only if it wasnt able to find a mapping in the EFI map
yeah its average linux code
th rest is mapped literally as normal ram
this logic is correct tho i think
device addresses wont be on the efi map
the rest will
"But what about hot(un)plug memory "
hotpluggable memory regions do appear in the memory map

yeah those would have appropriate attributes set tho
there's a memory type for the regions of the physical address space where hotplug memory can appear
which would default prot to ngnrne
fair enough
anyway, I think I'll be adding another memory manager to pmOS eventually
To do stuff like PCI bar allocation
maybe uacpi should pass to the map function a preference for the caching
well maybe you should have one then
just map it nc and call it a day smh
you are overthinking it
hmm
i wonder
could you induce SMM bugs by messing with MTRRs
you definitely can
how do they even manifest
which brings us to the next two questions
your pc hanging
framework should have opensource firmware iirc?
bruh
another open source dream shattered
the framework chromebook has open firmware lmfao
steamdeck can do coreboot they cant lmfao
its chromeos
the board that I have has a mostly open firmware impl available based on coreboot + edk2
kinda based
so its the standard chromeos coreboot/depthcharge setup
ikr
and steamdeck too
so stupid
by default?
wait
yeah, all aml tables it has are COREBOOT stuff
do you mean openfirmware or open-source firmware
oh damn
open source firmware
sorry not OF
obviously
OF on x86 would be stupid
they used it in one laptop per child
Only fans on x86
not cros_ec?
https://wiki.laptop.org/go/Forth_Lesson_9 here they discuss how to use forth to interact with the openfirmware device tree
https://docs.dasharo.com/variants/msi_z690/releases I should try this but I generally don't like flashing bios because then I have to redo all the fan settings and disable undervolt protection or I get very bad perf (I accidentally left that enabled after an update and were wondering why qemu takes multiple seconds to boot)
drivers/platform/olpc/olpc-ec.c
damn
anyway vote pls: #polls message
If this is accepted id like to do it before 1.0
what the hell does it mean for uacpi_kernel_get_thread_id to return a void *
what does the void * represent
is it a pointer to an opaque structure? is it an integer cast to a pointer?
opaque value that's unique for each running thread
thank you representative of the OOMF guild
afaik it's only used for recursive mutexes
void* is a default, this is an overridable value that you can set to anything
platform/arch_helpers.h
I love binding loosey goosey typesystems with vibes based meanings into Ada/SPARK, which has the strongest type system ever made
how can you tell
(you probably cant)
you don't like vibe based meanings? why?
i love a good bit of vibe-driven development
isn't this basically all of C?
damn this vote is closer than i thought
59% in favor
yeah thats pretty close
waiting for nyaux to vote
no
wait this is not even about map its just the width?
im definitely not removing map
cringe
u mean
the only case where map makes any sense is the pmOS setup, and they run uacpi with iopl(3) ANYWAY
its 2 loc to stub out io_map
no it doesn't make sense on arm, that's the thing
IO ports are a property of the PCI controller, not of the entire SOC
does uacpi not use io on it?
right but why does inb etc work on linux
on arm
without specifying any sort of base or controller address
i do not know
i truly do not know
I need to port pmOS to arm
i think it reads from base 0 though
which is. weird.
or maybe not idk
anyway linux sucks, systemio makes no sense on !x86 and it doesnt make sense anyway
also this is something you can add back if and when we find firmware that needs it
which i think is unlikely
one of the reasons why I just use iopl is because it's also kinda unclear what to do with threads
basically my thoughts
- potentially arm memes, although no one knows what aml on arm does
- microkernels
- abstractions for mapping both address spaces with one helper (like reactos)
- aligns nicely with AML since i can pre-map all opregions
- aligns nicely with pci and memory apis since they do map stuff
- trivial to stub out if it's a no-op in your kernel
ok fair
basically the only argument against is "lol it doenst need mapping are u stupid"
and well, my less apis to implement == better idea
but i think in this case its justified
if that exists as an arm instruction i got no idea. if it doesnt exist i bet its catching whatever the arm equiv to invalid opcode exception is and checking if its inb
nah, its a function: https://elixir.bootlin.com/linux/v6.12.6/source/arch/arm/include/asm/io.h#L241
Elixir Cross Referencer - source code of Linux v6.12.6: arch/arm/include/asm/io.h
it reads from here:
/* PCI fixed i/o mapping */
#define PCI_IO_VIRT_BASE 0xfee00000
#define PCI_IOBASE ((void __iomem *)PCI_IO_VIRT_BASE)
wrong directory
you want arm64
not arm
uh. no
#define PCI_IO_START (VMEMMAP_END + SZ_8M)
#define PCI_IO_END (PCI_IO_START + PCI_IO_SIZE)
ahhh ok
yep
#if !defined(inb) && !defined(_inb)
#define _inb _inb
static inline u8 _inb(unsigned long addr)
{
u8 val;
__io_pbr();
val = __raw_readb(PCI_IOBASE + addr);
__io_par(val);
return val;
}
#endif
what do they even map there
int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr)
{
unsigned long vaddr = (unsigned long)PCI_IOBASE + res->start;
if (!(res->flags & IORESOURCE_IO))
return -EINVAL;
if (res->end > IO_SPACE_LIMIT)
return -EINVAL;
return vmap_page_range(vaddr, vaddr + resource_size(res), phys_addr,
__pgprot(get_mem_type(pci_ioremap_mem_type)->prot_pte));
}
EXPORT_SYMBOL(pci_remap_iospace);
you're right
they just emulate x86
basically all PCI IO is mapped to one place
what
they pretend its a separate address space and remap it to a fixed location
so u use inb for x86 and other arches
hmm ok
what's nice is there's basically one usage of these helpers in the entire code base
like 1 extra for io write
@slim panther should we update uapi as well?
yes
Iirc I also mentioned it before
we knew that already
i wonder how linux manages collisions in that global pio region
honestly this feels so much like a linux-specific hack
if you have one controller where 0x1000 IO maps to 0xDEADBEEF and another where 0x1000 IO maps to 0xBEEFDEAD so there's no collision technically
but in that global region offset 0x1000 would collide
also, i'd advise against adding this to uAPI
this?
we aren't adding that
we will have bar_map and bar_read/write, and normal port io for legacy devices, aml etc
define "normal port io" tho
that does not work for uDRM
the vga device bar names the registers iirc
the bochs gpu certainly doesnt have that in the bar
wtf?
okay then
allow udrm asking for io ports not covered by a BAR
but still against the pci device
it wouldn't
like it doesnt know what pci device to associate it with
why would it have to take in a pci device anyway?
lets put it this way, whats the downside of a raw legacy io uapi interface?
I think what linux does it more or less the same as on x86: it will give each device a different range if i/o ports even if they are on different controllers
that it breaks if you have more than one pci controller
So there no collision
ohh
ah, they mess with BAR assignments?
that sounds so annoying to implement
that would make sense i guess
its legacy io so its x86 specific
yes, sure, automatic BAR assignment is not a thing on most platforms
That's an x86 special
Yes, true.
but yeah this sounds very annoying to correctly implement
Well, uefi has to implement this correctly for x86 already
if you make it only an api on x86, then cool
If they support multiple segments at all at least (iirc ovmf doesn't)
you only have one pci controller on x86 though
afaik
No, servers have multiple ones
at least larger servers
interesting
chromebook has pci segments lol
They have one segment per socket
oh lmao
like my one?
neat as a testing platform (if the charging port worked at least)
it was either your chromebook or qualcomm's windows laptop
the rpi5 technically (as per linux) has 3 segments 
ah okay it was sdxe
because linux just assigns a new segment number to each dtb pci controller node
ngl i love how the open source firmware is the clean and well written one
and then the closed firmware is just lolnope
aaaah
yeah that makes sense
they have different pci windows
yeah, and segments are not really a thing outside of acpi/os internals so
who guaratees that tho
u can have both pci roots have a bus range of 0-3 or something
all 3 controllers have a 00:00.0 device that's a root port (and its configuration space is actually just the controller's mmio registers
)
bruh yeah
like the driver does if dev == 00:00.0: return mmio_base
else: write dev to window register, return pointer to window
how do they solve races against this window?
iirc the driver provides the read/write functions and not just the map function? and in those it takes a lock on the controller
also notice how thats incompatible with MCFG 
ah
ecam is a luxury on shitty embedded devices ig
Does the acpi firmware for raspi just not expose pcie?
on the pi4 (which has the same controller) it exposes xhci as an acpi device directly, i assume on the pi5 it does the same for the rp1
Doesn't this apply to all aml blobs? 
true
for the user-accessible pci connector on the pi5 they have a hack to expose the single function thats at 01:00.0 via MCFG
by pointing MCFG at the 4k window in the controller's mmio, and using os-specific hacks (one for windows and one for linux) to make sure the os only scans for 1 function at the root
:^)
most stable arm acpi implementation
oh no
api changes

i dont want to replace my 32 lines of code with 8 lines of code
😡
(0000000000) successfully loaded 1 AML blob, 1702 ops in 17ms (avg 100117/s)
fast
ironclad?
mutexes etc returning NULL
You returned nullptr
how is it so slow lol
Test uacpi on serenityos 
well that i don't know, it's still faster than some other OSes here
is this tcg
well true reactos got like 30k lol
yes, from where?
mutexes should theoretically be implemented
too generic
streaks says his alloc cannot give null
I would say size=0
maybe try setting log level to debug
create_{event,mutex,whatever}
But infy tests for that
size=0 is handled
and it cannot return null because it runs OOM handlers internally
ok how do i make it debug verbose then
show kernel api code
wdym
if you are brave enough to try to debug Ada code lol
show the implementation of the uacpi kernel api
it's long
thats not big at all
trace will show you the opcodes being executed
does uACPI do always aligned mmaps
which should tell you what uacpi is trying to do
never
never aligned or never misaligned
Every time I see someone post one of these I think: "Soon, BadgerOS, too, will run the benchmark"
would uacpi take a failed mmap as out of memory itself
even when no out of memory status is returned
almost always misaligned
ah
so it's the kernel's job to align the address, map the required page(s) and return an address that can be used to access them
makes sense
yeah, just round_down(), map, and add diff

so like
once you do initialize/load_namespace (we fixed the issue btw, it was that it needed events to be created as non-null for some reason)
For some reason?
lmao]
Is it unclear why
mint what are u smoking
how else would you signal an out of memory condition to uacpi
outside of returning null
also how does a null event work lol
i say for some reason because it doesn't seem to use events?
or are events mandatory?
well idk it seems to work for the time being
it works with events being a literal no-op
Because its not contended in qemu
why do you not use a mutex?
can you use a mutex?
You cant
why?
The way firmware tells you its relased is via an interrupt
okay sorry i dont understand the issue
like it would be ideal if you only used one concurrency primitive as much as possible/feasible
When uacpi tries to acquire it, it may be used by firmware
Event is a thing in aml
U cant not have it
If it is, you block on an event until its released
The way u know its released is via an irq
yeah so if you see that it is contended, you acquire a helper mutex