#uACPI - a portable and easy-to-integrate ACPI implementation
1 messages ยท Page 66 of 1
why not take a trait ref
thats what i wanted to do
zuacpi update: added binds for object_get_type, and eval and get for string, buffer, and string_or_buffer
@fiery turtle why is it eval_buffer_or_string and get_string_or_buffer
why are the two different
Aml defines them as separate object types
A string is guaranteed to be null terminated in uacpi
(internally it uses the same object storage ofc)
Some feature plans (or ideas) for uacpi:
- Ability to precalculate the space needed for the early table buffer
- (behind an option) An ability to attach a user object to a namespace node
- An extended version of for_each_subtable that allows arbitrary headers via a callback (not just madt/srat entries)
- table.h has a lot of naming inconsistencies, so these should be fixed for the next major release
- Fix
uacpi_generate_absolute_pathto no include trailing_, or have a separate function that outputs prettier paths - Fix random scattered globals, at least follow the g_ convention for them
- Maybe add helpers for static/compile-time spinlock/mutex creation without allocations
- Consider offloading uacpi state into a context
- UACPI_DISABLE_PCI
- An overridable 64-bit division helper
- Check how NT handles missing arguments for methods
Are you planning for for_each_subtable to just deduce the type based on the signature?
(so like the api won't even change)
@fiery turtle given
uacpi_status uacpi_object_resolve_as_aml_namepath(
uacpi_object*, uacpi_namespace_node *scope, uacpi_namespace_node **out_node
);
do i need to pass a ptr to the uacpi_object that i currently have there or the ptr that i get from uacpi when creating a new a new object?
you pass in a string object that you already have
you mean uacpi_namespace_node?
no i mean an object
this function takes a string object that the aml provided you
which contains a path
that path is then resolved against a scope
and gives you back the namespace node that it meant
the problem i have is does the function want its input as call by value or by reference?
wdym by that?
in C all arguments are by value
do you mean which arguments here are output?
only the out_node argument
even if you wanted, u cant make a uacpi_object manually and pass it by reference (pointer) because its an opaque type
i can pass a ptr that points to the pointer i got from uacpi that represents the object or i can just directly give the function a copy of that ptr
//Call by reference
fn call(thing: &MyStruct)
//Call by value
fn call(thing: MyStruct)
the object is not modified by the function
if thats what you mean
like you literally cannot pass an object by value in uacpi
its an opaque type
all you have is a handle
at all times
no I know that, why is one buffer or string and the other function string or buffer
the order in the name is different between the two functions
also stuff like the object type here is why I love zig's opaque type, which just let's me define a thing that's allowed to have a pointer to it but not be dereferenced
Added here #1217009725711847465 message
i found my error, also do i have to check that the handle aka the ptr to the object/namespace/.. that i get from uacpi is never null?
it's guaranteed to not be null as long as the return status is OK
oh for the subtable iteration, any plans to support the bonus stuff in the GTDT? or leave that to custom headers
doesn't impact me either way because zuacpi can't use c macros and anything that takes a callback is to be avoided if possible because I lose some good zig qol that way (zig uses iterators as the main idiomatic pattern anyway for that)
What is gtdt again?
generic timer description table
it's for arm
it is in the proper acpi spec though
Perhaps could be handled by new for_each_subtable_auto
the usual chapter for tables
the thing with the gtdt is it's got two lists of different subtable headers iirc
well slightly different
it has one list of subtables but one of the subtable entry types has its own list in it
thankfully the sub-sub-entries are fixed size now that im lookin at it again lmao
and if i only get the object as a return and no status?
Can you give an example of an api
uacpi_object *uacpi_object_create_package(uacpi_object_array in);
Null is returned on OOM
oh also, zuacpi technically has api autodocs now
insofar as my kernel uses it and the autodocs i generate for the kernel include all the modules it imports ๐
Thats cool
note that this is technically a bit out of date because i dont have any ci set up so the website has to be manually updated by me
so how the autodocs for zig actually work is kinda bonkers tbh. theres a zig module in the source for zig itself that imports the literal actual zig parser and compiles to wasm, and then it has a small js wrapper and loads a tarball of the sources and the wasm module parses the doc comments out of the actual literal source tarball on the fly
and then that generates html using the dom api stuff afaik
so when you load those autodocs its literally loading a source tarball using the zig std tar api and the actual from-the-compiler zig parser to extract the autodocs
https://khitiara.codeberg.page/imaginarium/docs/api/#src/zuacpi/gtdt.zig but that also means it can just pull up the source from the tarball whenever
(i did replace the handmade html and css parts of the autodocs to match my site but i left the wasm and js fully intact other than finding and fixing a bug in it that made it break if you build the docs on a platform that uses backslash as the file separator)
Damn
the old-school html purist in me hates this wasm nonsense. the lazy in me is like meh its fine i leave it
i dont really think the site is that that impressive but ive been doing osdev for like two and a half years now and webdev for literally like 5-7 times longer than that
tfw i realise ive been doing webdev for longer than @north holly has been alive ๐
uacpi api reference when
Header comments
What is it
Cool
If someone was willing to actually host a website or something that contains the docs that would be cool, but I have no idea how that stuff works and have nowhere to host so
I'm not sure how your comments are written atm, but if it follows the rustdoc/duck convention then I could set it up for you
github pages
its static pages so github pages works fine
Nah it doesn't follow any convention as far as im aware
technically i dont think it needs to be static for gh pages, just client-side only if theres dynamic stuff
That could be fixed ofc but thats effort
Will it work without proper convention?
yeah, or I can adapt the comments
theres no convention
just
/**
* Something
*/
Sure I mean thatd be cool
two stars
or ///
but like it doesnt try parsing doxygen-style annotations like @param or whatever
It just does stars without the second one atm
neat
no its a uacpi_size
yeah that's likely a libclang problem
not sure yet
ok no I forgot to add -Iinclude
now it works
maybe you should make sure it parses without errors
ok it's all working perfectly now
I will try integrating it into the CI
do you like that CSS @fiery turtle or do you prefer something more like this: https://rdmsr.github.io/duck/
is that just white vs black theme or is something else different also
i mean idk but i think your website looks better
indeed
well okay imma set it up with the light theme for now, and I'll let you look at it live and change it if you want
lmk if you still prefer the other theme (I personally think that one looks nice, but I can easily change it so its no big deal)
obviously some comments are rendered weird, but that's because they were not written with the tool in mind. Now if you want prettier comments, you'd need to write them using markdown syntax
Well other than it being unstable guess not
It will have way less noise I suppose
yeah that's what I figured too
I think it's as simple as changing the glob from **/*.h to *.h
Yeah
what kinda symbol is internal?
just wanna check whether it got included
Like it literally listed uacpi_memcmp etc
Can osdev wiki stuff be copied there also?
Would it be a separate repo?
I think a separate repo would be better, I dont think a separate branch for literally a different thing is how git is supposed to be used
you'd have to use your secret token and stuff in the workflow but I think it'd work
A lot of comments changed here are in internal/ also
Hmm
does it really matter though? 
ok yeah maybe
Less code churn
I will try restoring them
That would be nice
Ill think about whether it should be a sep repo, idk yet
How do you add new stuff to the website?
Like stuff from the wiki etc
Its all on the wiki so not yet
I'll do the wiki thing then I'll do it
Why cant it be on master tho?
You have like 2 there?
and github pages works really well with "deploy from branch"
see my gh-pages branch
Hm
the workflow generates HTML and pushes it to that branch
github pages publishes it
I think other projects use separate repos usually, I can make uacpi a submodule there or something ig?
Or it can clone it itself or smth
yes, you could do that
but then youd need to trigger it on every uACPI push?
or maybe on every release you regenerate the docs
Yeah on release could make more sense
How hard would it be for you to make a repo where it automatically clones uacpi and then we can just move it into the uacpi org?
not hard
I think that would be ideal
is there a reason to push them to git at all
And I guess comment changes can be in the main repo ofc
actually I think I can still PR, but I'd move the workflows to another repo
github pages
Yeah you pr the comment changes right
the html files dont need to be in git for pages to work afaik
at least my workflow doesnt do that
Sure
god bless the clanker
though I should remove that header and instead name the thing "Example usage"
yeah I just build the docs and push straight to gh pages, the build artifacts never enter git afaict
Yeah
I thought you had to deploy from a branch
ahh
ok thanks
I think this will be github workflows wrestling more than anything 
๐
actually I'm thinking I can move all the config and static stuff to the docs building repo
yeah that's better
ok @fiery turtle my PR is a lot of back and forths so you should probably squash it, but I think this is better
I basically only PR the comments, then you should create a repo named uACPI.github.io that I can be contributor to or something
You can make the repo yourself and we can move it into the org as well, we did that for zuacpi and uacpi-rs before
perfect then
Can you fixup all commits yourself? Also im not sure we need platform/ comments or struct member comments to be changed, or can it detect those also?
yeah it can detect struct member comments
Cool then
Hmm idk, maybe its fine
Ah ok
Yeah cool
Can u do a quick interactive rebase to fix them all up into the first commit? The github default squash message is ugly
git did that
lol
git clones duck and uACPI, builds docs from uACPI source and pushes it
I wonder what will happen if you ask a clanker to produce an aml interpreter
ok great it works
how do we move it to the org?
https://github.com/rdmsr/uACPI.github.io this is the repo
https://github.com/wrmsr this is my evil twin
@frank canopy do u remember what we had to do to move zuacpi to the org?
tho you should maybe merge the PR beforehand though
add the owner user to the org and transfer ownership of the repo to the org in that order
iirc
can u get rid of that commit description real quick?
sure
ah ok
ill send u an invite in a sec and then u can move the repo into the org once you're in it @hallow marten
alright I changed the desc
thx, ill merge once ci finishes
you'll have to change the github pages repo settings though
I cant do that
(I shouldn't be able to anyway)
what should be changed?
how do we retrigger it manually e.g. if a new release happens?
damn yeah
thats nice
you just click on "re-run all jobs"
i can add that link to the main repo as well
minor nit but hyperlinks in the markdown file dont work ๐ข
the ones that point to some markdown sections also ig
ok that's my bad
also it seems we're back to int and comments don't appear there but I guess thats because the pr is not merged yet
It seems messed up on Firefox.
mhm well I cant autogenerate them, you have to do something like # More detailed overview {#id} then link to #id
aaaaa
aaaaa
fuck
what
lmao
what screen res? This is likely an issue with the table
table looks fine for me i guess
1080 width by 1920 height.
That is on my vertical monitor.
It happens every where.
yeah same
@fiery turtle I pushed a fix for the int stuff, should be up soon
its reproducable if u slowly resize the page
I'll check it out
Yep. It is only an issue for me on the default zoom level on my vertical monitor. Zooming out fixes it and zooming in transitions to a different layout.
yep
cool thx
the only issue is aliases sometimes refer to themselves
I'm not sure how to fix that
I'll push a fix and retrigger eventually
btw, tl;dr on how to write comments from now on if you want them to show up better:
- use markdown
- you can link to names using :: links, so (or the other way around, I always forget markdown syntax)
- This is how you document members:
struct hello {
int a; /**< Some member */
}
- There are also mermaid diagrams if you're into that kinda thing
Create diagrams and visualizations using text and code.
it's "inline documentation"
I think /** should work too
mhm
I didnt change the message but removed the description
thats way better than docs: generate documentation since its not even what it does 
done
also note that since internal and platform arent used in the generation it wont generate descriptions for like uacpi_u64 and friends
that's fine I think
if you do want to write more extensive documentation, this is how add chapters and stuff:
https://rust-lang.github.io/mdBook/format/summary.html
Create book from markdown files. Like Gitbook but implemented in Rust
that is what managarm uses
idk why you'd write a book on uACPI though 
mdbook is sick
well u dont have to call it a book
my thing can generate mdbook chapters and stuff
but reST is uhhh.. slightly cursed 
uACPI is my test subject before I integrate in managarm btw 
yeah but we wanna integrate the api reference with it
ah
yeah markdown is way better and markdown isnt that good
btw the css is heavily inspired by kernel.org idk if you noticed 
Yeah I quite like markdown but it doesnt have all the things I would like, but then if u add them u slowly become reST....
never heard of it lol
asciidoc is also nice
yeah
most people use emacs only for org-mode
lmao
interesting
with org-roam you can have a system and stuff like obsidian
when markdown stops cutting it I just start writing html by hand like the old-fashioned woman I am lmao
@hallow marten so whats the right way to write api comments with parameter highlighting etc, is it documented somewhere?
no i mean like
nope never used it just like rust in general lol
so is there any actual difference between /** and /**<?
I don't think so 
lol
it's literally just a doxygen thing I think
it just looks uglier than **
windows ci runs for 10 years because it also checks openwatcom
I was about to say
special support for exactly one person that uses openwatcom 
at least iretq added multithreaded tests so its way faster than it used to be
alright merged
ok imma retrigger docs
cool
cute duck is the best feature
CI will be faster eventually when I figure out how to prebuild binaries
you're right, I must've forgotten a link somewhere
is it possible to improve code formatting here a bit?
no

i see
ah
ah yeah you're right
but I still saw that bug somewhere where it shouldnt
the fix should be simple if alias: dont refer to the same alias
https://uacpi.github.io/alias.uacpi_gpe_triggering.html the enum is not clickable also
ah
Yeah i think tahts not the type of the callback 
mhm yeah ok that is strange
that shouldnt happen
I'll take notes of these issues and fix them eventually, if you find any other let me know
sure, thanks, overall thats pretty cool anyway and a huge upgrade over just header comments and osdev wiki
I think what's happening is that it expects only one type, but since it's linking to "multiple" (return type and arguments) it's kinda broken
Uacpi test suit might be complete enough to be able to run claude in a loop or something until you have uSlop
oh yeah probably, its just gonna take a lot of time
If I had a lot of cash that would be an interesting experiment
Finance me @anthropic
lol it says windows uses acpica?
and macos...
does macOS have a custom one?
yeah ofc, i think they have their own impl
I would've thought they'd just use acpica since they don't have to worry about compatibility with random aml
maybe people who are more familiar with macos could confirm
looking at this panic screen backtrace someone posted it does use acpica
which AI is that
thats very surprising to me
thats gemini 3.1 pro
i've never seen an apple contribution in acpica code
i mean i get that they're doing arm now but
but yeah apparently AppleACPIPlatform.kext is based on heavily modified acpica
@fiery turtle i fixed all the bugs I think
the only caveat is that you cant click on types in function pointers
thats because they're a PITA
Thanks, that was fast
๐
i'm nearly done with types.h in what order should i do the other headers for uacpi-rs?
i'm assuming u already have tables, uacpi.h contains most initialization functions, after that maybe namespace stuff
for zuacpi i started with uacpi.h and tables.h, and then from there namespace.h and just adding things as i use them in practice - i figure the longer it takes me to get to using something the less likely someone else using zuacpi will need it immediately
so basically same recs as infy has
does
uacpi_status uacpi_object_assign_package(uacpi_object*, uacpi_object_array in);
copy the supplied objects to somewhere else or does the package object now directly references the objects supplied by uacpi_object_array in?
maybe
letsgo
any chance of getting the IORT table in uacpi? ill need to create separate definitions for zuacpi anyway but might be good to have em in the base thing too
what does iort do again? I seem to have downloaded documentation for it but I don't remember when or why
yeah idk what that is
i usually add tables as I go, but I accept PRs for any tables
IORT (IO redirection table) tells you how to make devices to device ids used by the GIC's MSI stuff
and i think some other stuff but thats the bit i need it for
it also tells you which devices are connected to which iommus on aarch64
because you can have multiple SMMUs connected at once
if i ever feel like writing C versions of the tables zuacpi has that uacpi proper doesnt ill PR them then
basically doing the same thing with zuacpi of adding tables as i go
why is zuacpi needed? cant you just @cImport
well for one cimport is getting removed soon in favor of the TranslateC build step but also zuacpi is written as idiomatic zig (also cimport/translatec cant translate all the macro helpers that uacpi has because its a bindings generator)
(and also also zuacpi provides the log alloc and free kernel apis for you on top of that)
mostly its to organize and wrap the bindings in a zig-idiomatic way though
stuff like error sets and error returns, slices instead of pointer and length, stuff like that
same difference as uacpi-rs vs just raw bindgen if youre using uacpi in rust too
the one is idiomatic wrappers the other is raw bindings
tbh the biggest reason for zuacpi existing is that cimport/translate-c used to be way way worse at its job and i needed to fiddle a lot to make things work lmao
heres an example of it, at least schematically
and another example where root complex a isnt hooked to the SMMU but does generate MSIs
it can also have reserved memory ranges and at least a few other things
alright zuacpi has the IORT (a basic version anyway, missing a few things that i dont need yet for my kernel) and also i added the MADT structure for the GIC ITS
PSA: uACPI 5.0 will have a distinct return value (UACPI_MAP_FAILED) for uacpi_kernel_map to make 0 a valid return value to allow client code that identity maps all addresses + AML that erroneously tries to map physical 0
Yum
namely some crappy xiaomi tablet that does that
oh btw its not official-official yet but https://github.com/tianocore/edk2/issues/11148 exists and is already in acpica
Code First Item Overview Arm has architected a new Generic Interrupt Controller (GICv5). The GICv5 architecture definition can be found here: https://developer.arm.com/documentation/aes0070/latest/...
The GICv5 adds the following MADT structures:
- IRS
- ITS Config Frame
- ITS Translate Frame
The ACPI spec ECR is at https://github.com/tianocore/edk2/issues/11148
Change-Id: I35a46714de862edd6d0...
cool
not sure if you want to wait for it to actually get into the spec or not but figured it was worth bringing up
๐คทโโ๏ธ
yeah thats my feeling too
i don't know what i expected but it's hilarious that uefi change proposals are apparently submitted as .docx in github issue comments here 
lmao yeah
ok im getting IRQ resources (not extended irq) that all report irq 29 (0x17) only and i dont think thats possible
since the basic irq resource is a 16-bit mask
@fiery turtle any ideas how i could track this down?
ah found the issue, was on my end
bug was in zuacpi in fact and a fix has been pushed
Cool
on that microsoft grind
was some leftover manual field alignment in the resource types and i didnt realise that setting the alignment of the first field to 8 would force there to be extra padding after all 6 byte fields and as a result the irq list trailing array thing was doing bad pointer math and overrunning into something else
the manual field alignment didnt need to be there anyway so i just removed it and that fixed it
Apparently in Gemini lake bioses are supposed to set the HW_REDUCED_ACPI bit
Also the fact the ucode handles the timer is cursed af
that is cursed
though weren't there netbooks without acpi pm timer already?
isnt gemini lake that cursed mini nuc thing
Gg
it's hilarious that the timer is still emulated by microcode
nt must boot
lol
@vast kestrel can u send that pdf btw
thanks
yeah it's that one
Its the low power pentium gold/silver mobile CPUs
Released in 2017
My laptop has the pentium silver from that generation, and its very slow. Base clock is 1.1GHz, boost is 2.7GHz, 4 cores. Also only passive cooling.
That thing must be torture to work with
Yep, it really is. Takes a couple of seconds for it to register the power button has been pressed. Windows takes a long time to boot, but it isn't too bad after that. I once tried gentoo on that thing.... Was not a good idea.
I guess it can be good as an osdev machine for testing stuff
Yeah
Optimizations in my memory operations worked wonderfully
tho idk why it still says it's slow
maybe my timers are screwed up?
and chromebooks too
PSA for those 2 people that use UACPI_FORMATTED_LOGGING, uacpi_kernel_vlog is getting removed in 5.0
i guess it doesnt even break backwards compat in any way, it just wont be a function exposed in the header
since it was never used by uacpi anyway
formatted logging is where you provide your own printf, right?
oh also id like to request replacing your newline at the end of logging with something that can be turned off as a feature (obv on by default)
(idea is to replace the final trailing \n with a macro using that stupid c thing of adjacent strings join and then let that macro be defined as nothing if you dont want trailing newline)
It basically switches logging api into printf mode
What's the use case for that
zig's entire ecosystem and my own logging infrastructure is all built around never having trailing newlines in log messages
and having to use std.mem.trimEnd every time is annoying when it could just be never sent in the first place
Ill see what I can do
๐
its not a huge deal itd just be nice to maybe have
(the other related idea would be an option to replace line endings altogether for carriage-return ecosystems but i dont have any use for that its just an idea that popped into my head)
yeah i think it should be very easy to implement since all logging in uacpi internally is already done via macros, i can just add a UACPI_END_OF_LOG_MSG to config.h something
the hard part will be making a script to strip \n from all existing log strings
you can do that with any good find-in-files editor tbf
maybe
maybe UACPI_START_OF_LOG_MSG as well so u can add a prefix or something
that would be cool
mhm
heres a list of every use of a log function in uacpi
thats the easy part
cant u literally just grep for \n"
hmm maybe lol
yeah but now replace with UACPI_LINE_ENDING or something
its a simple search-and-replace I think
this patch works
all logging code already goes through uacpi_log_lvl
yes
thanks jetbrains for a good find-replace thing for getting me the patch i put above lol
git am "C:\Users\infy\Downloads\remove-trailing.patch"
Patch format detection failed.
wtf do u want
lmao
tell Copilot to manually apply that patch XD
it works wonderfully
may need to dos2unix
since im on windows it might have some line ending bullshit
doesnt seem to have done anything ๐ญ
rip
try what i told you
i made it apply 90+ patches bc they did not want to apply bc of the same error
what aboiut git apply
and it went and manually applied them
because i didnt do git format-patch
what about patch
it will prob not work
so its a raw patch and you might need apply instead of am
it didnt error out but it also did litearlly nothing lmfao
oh nvm
it worked
cool
pog
yeah git am is for taking a format-patch output with authorship and commit messages and all that afaik
theres also places where it might have absolute paths in hte patch
and i had 90 patches to apply
would patch < file.patch work as well here
which would break
or patch -i file.patch yeah
so this stays?
void uacpi_kernel_log(uacpi_log_level, const uacpi_char*);
this part is not related since its not UACPI_FORMATTED_LOGGING
okie
And... now I put #define UACPI_START_OF_LOG_MSG "%s" and everything breaks.
be my guest lol
if you do thats your problem lmao
@frank canopy your patch didnt catch stuff like
uacpi_trace(
"%sactivated all '%s' opregions controlled by '%.4s', "
"%zu _REG() calls (%zu errors)\n",
ah yeah not surprised, i just went up to the next quote because i didnt want to overclobber
There's an argument to instead doing it like printf("%s" fmt "%s", UACPI_START_OF_LOG_MSG, __VA_ARGS__ __VA_OPT__(,) UACPI_END_OF_LOG_MSG);
why is this better?
because it allows me to use %s or literally any string as the "start of log msg" bit.
although there's also an argument against it, because it adds more indirection to logging (now you have to parse the %s whenever you are printing anything).
or literally any string as the "start of log msg" bit.
thats already how UACPI_START_OF_LOG_MSG works
if you insert printf reserved stuff there for whatever reason thats a u problem
indeed it is
like i just dont see the benefit of adding a ton of runtime cost just to support bad strings
esp when its not user-provided anyway
yeah like its a compile time constant
i think the solution is to switch to C++ and parse the format strings at compile time
if u insert %s there the program wont compile
switch to zig 
since it uses attribute format
ah that works too
yeah
thats literally what the zig uacpi bindings are called lmao
yes hence the 
@frank canopy I pushed the feature to for-5.0 if u wanna give it a shot
let's see if this compiles on OpenWatcom at all
lol gl
ill test in a bit, im in a groove on what im writing atm and dont wanna lose it
you gonna put a ifndef default for end of log to \n to maintain compat?
i added \n in config.h to maintain compat
if config doesnt define it log.h will define to nothing
Oh right i should also wrap it in ifndef here so that u can override via gcc and not config.h
yeah id appreciate that, overriding by the compiler is way easier for zuacpi's build setup
Do you have something like linux pr_fmt
Ill push it if this last part succeeds 
yep
i have stuff like this in most files
Damn with this patch I can just do
Thats really convenient
Also good news openwatcom seems to have liked the patch
๐ nice
thanks for the idea, I think overall its a W for everyone
glad itll help others
I saw a ton of people complaining about it because of latest flanterm changes
It now requires \r\n to do a newline
if i could make zig use \r\n for multiline strings i would for that reason too
but its way too convenient to use the multiline literals to not use them anyway
ok time to test the new stuff
alright it worked perfectly right out of the box so zuacpi has been updated and pushed to use the for-5.0 branch for now
Cool
Hmhm I'm encountering a strange issue. I'm getting a page fault in tables.c:149 from initialize_from_rxsdt at this line uacpi_memcpy(&entry_phys_addr_large, &rxsdt->ptr_bytes[i], entry_size);. The thing is it works if I run with -smp 1 or -smp 4, but with smth like -smp 8 it crashes after FACP to load APIC
UACPI: starting uACPI, version 4.0.0
Map: 0x00000000000f5000-0x00000000000f6000 -> 0xffff8000000f5000-0xffff8000000f6000
UACPI: RSDP 0x00000000000F52C0 00000014 v00 (BOCHS )
Unmap: 0xffff8000000f5000-0xffff8000000f6000
Map: 0x000000000ffe2000-0x000000000ffe3000 -> 0xffff80000ffe2000-0xffff80000ffe3000
UACPI: RSDT 0x000000000FFE259E 00000038 v01 (BOCHS BXPC )
Unmap: 0xffff80000ffe2000-0xffff80000ffe3000
Map: 0x000000000ffe2000-0x000000000ffe3000 -> 0xffff80000ffe2000-0xffff80000ffe3000
Map: 0x000000000ffe2000-0x000000000ffe3000 -> 0xffff80000ffe2000-0xffff80000ffe3000
Unmap: 0xffff80000ffe2000-0xffff80000ffe3000
Map: 0x000000000ffe2000-0x000000000ffe3000 -> 0xffff80000ffe2000-0xffff80000ffe3000
Map: 0x000000000ffe0000-0x000000000ffe1000 -> 0xffff80000ffe0000-0xffff80000ffe1000
Unmap: 0xffff80000ffe0000-0xffff80000ffe1000
UACPI: DSDT 0x000000000FFE0040 0000231E v01 (BOCHS BXPC )
Unmap: 0xffff80000ffe2000-0xffff80000ffe3000
UACPI: FACP 0x000000000FFE235E 000000F4 v03 (BOCHS BXPC )
Page Fault at address 0xffff80000ffe25c6 with error code 0
- Non-present page
- Read access
- Kernel-mode
What does your kernel api look like
Is it possible u handle this incorrectly?
map1 = map(0x1234);
map2 = map(0x1234);
unmap(map2); // also unmaps map1
void *uacpi_kernel_map(const uacpi_phys_addr addr, const uacpi_size len)
{
const u64 aligned_address = math::align_down(addr, memory::s_page_size);
const u64 address_diff = addr - aligned_address;
const u64 aligned_length = math::align_up(len + address_diff, memory::s_page_size);
for (usize i = 0; i < aligned_length; i += memory::s_page_size) {
vmm::map(
vmm::get_kernel_page_map(),
aligned_address + i,
aligned_address + i + boot::get_hhdm_offset(),
vmm::Attribute::Write);
}
return reinterpret_cast<void *>(addr + boot::get_hhdm_offset());
}
void uacpi_kernel_unmap(void *addr, const uacpi_size len)
{
const u64 virtual_address = reinterpret_cast<u64>(addr);
const u64 aligned_address = math::align_down(virtual_address, memory::s_page_size);
const u64 address_diff = virtual_address - aligned_address;
const u64 aligned_length = math::align_up(len + address_diff, memory::s_page_size);
for (usize i = 0; i < aligned_length; i += memory::s_page_size) {
vmm::unmap(vmm::get_kernel_page_map(), aligned_address + i);
}
}
That could be
yeah from your code thats the bug
if you do it like u do it you need a reference count
npnp
fuck you acpi, if it wasnt for this one subentry these could all be 4-byte aligned but noooo
zuacpi updated with SRAT and also a bunch of refactoring to make things more idiomatic which is breaking changes but hopefully wont be too unintuitive to update to if theres anyone other than me using zuacpi
Lol
brought to you by the people behind the xsdt 
somehow i forgot to actually push this last night but ive done that now
Very good and detailed explanation of how s2idle works
https://docs.kernel.org/arch/x86/amd-debugging.html
I'm afraid that needs more ACPI knowledge than you think
Because it's not explained what actual state the CPUs themselves enter
it does say ACPI C3
So C3 is basically paused but still powered on
Can't immediately find where ACPI specifies what rebooting and shutting down are
Is it that you place it in S5?
And I suppose for reboots, cause something else to immediately wake afterward?
no, reboot is just a separate register
I see
but u can reboot via a deferred alarm yes
So I had correctly identified S5
s5 is the full shutdown state
check
C3 is not running
any non zero C state means that the cpu is not running (i.e. not executing instructions)
C3 is clock off, cache coherency not maintained
The states in which the CPU keeps running (just at a slower clock rate) are called P states
^
Ah right
On AMD systems, itโs not possible to simultaneously support suspend-to-RAM (S3) and suspend-to-idle (s2idle).
wtf
i think they mean it's possible to change at runtime via sysfs, but one mechanism is a direct replacement for the other
added madt local x2apic and x2apic nmi subentry binds to zuacpi
what about DMAR?
I was doing iommu stuff and encountered the lack of dmar in uacpi (I might be on old version)
there are quite a lot of acpi tables though, and adding all of them could result in undesirable bloat to codebase size
update uACPI
Its just a header with structs, all it affects is nanoseconds to compile time
So we can add every existing table if someone wants to do that
No, but I added that table a month ago (which broke msvc in the main branch at the time ๐๐)
The AMD table was more obnoxious though
Idk, I can add that too, once I do iommu in my kernel (which I planned on doing after bash I guess?)
what caching mode is assumed for uacpi_kernel_map?
Writeback if referencing normal ram, uncached otherwise
okay, i suppose i have to check from the memory map
Yeah
You can also just rely on MTRRs to set the right one for you
And just always map wb
yeah, i didn't think of that
I'm finally adding pretty advanced table info iteration api to uacpi
also helpers to get/put table by the internal index in the array, as well as the table count
the info iteratio api is mostly for more niche uses cases and it provides a ton of additional info:
- the origin of the table: whether it came from firmware or client code, whether it has a virtual or physical origin
- whether the table was already loaded by the aml interpreter
- whether it passed the checksum check
- union { physical, virtual } address depending on origin
- number of references currently alive
out of curiosity, how do you even know if the table is virtual?
virtual is either uacpi_table_install or LoadTableOp/LoadOp from AML
cool
These are the origins:
typedef enum uacpi_table_origin {
/**
* A table that originated from a physical address provided by the firmware.
* All tables discovered via RSDP have this origin.
*/
UACPI_TABLE_ORIGIN_FIRMWARE_PHYSICAL = 1 << 0,
/**
* A table that was dynamically loaded by the AML firmware.
* This includes both Load/LoadTable opcodes. Such tables live in a
* heap-allocated kernel buffer.
*/
UACPI_TABLE_ORIGIN_FIRMWARE_VIRTUAL = 1 << 1,
/**
* A table installed by the client code via uacpi_table_install_physical().
*/
UACPI_TABLE_ORIGIN_HOST_PHYSICAL = 1 << 2,
/**
* A table installed by the client code via uacpi_table_install().
*/
UACPI_TABLE_ORIGIN_HOST_VIRTUAL = 1 << 3,
} uacpi_table_origin;
uacpi_table_install feels like one of those things that almost never comes up that id somehow end up using anyway someday
its better than what winload does to add custom acpi tables though dear lord
(winload, in order to install extra tables from software, creates its own xsdt from scratch based on the firmware one but with its tables added and also stuff filtered/etc as needed, and then its own rsdp pointing to that that it gives to the kernel and acpi drivers)
the most common use case is probably just adding missing firmware devices that some driver looks for
yeah thats what they do it for iirc
im on the wrong machine to actually check for sure
i think it was IBFT? could be misremembering but im sure the first letter of the signature was I
I think this will be the final API:
typedef struct uacpi_table_info {
/**
* The index of this table in the internal array
*/
uacpi_size idx;
/**
* Size of this table in bytes
*/
uacpi_size size;
/**
* Signature of this table
*/
uacpi_char signature[4];
/**
* One of 'uacpi_table_origin' values
*/
uacpi_u8 origin;
/**
* This table has been processed & loaded by the AML interpreter.
* Only applicable for AML bytecode tables.
*/
#define UACPI_TABLE_LOADED (1 << 0)
/**
* This table's checksum has been checked. The checksum is valid if
* UACPI_TABLE_CSUM_BAD is not set.
*/
#define UACPI_TABLE_CSUM_CHECKED (1 << 1)
/**
* This table's checksum was found to be incorrect.
* Note that if UACPI_FLAG_PROACTIVE_TBL_CSUM is enabled alongside
* UACPI_FLAG_BAD_CSUM_FATAL, such tables are never installed in the first
* place.
*/
#define UACPI_TABLE_CSUM_BAD (1 << 2)
/**
* A mask of UACPI_TABLE_* flags
*/
uacpi_u8 flags;
/**
* Reference count of this table
*/
uacpi_u16 reference_count;
} uacpi_table_info;
typedef uacpi_iteration_decision (*uacpi_table_iteration_callback)
(uacpi_handle, uacpi_table_info *info);
/**
* Iterate every installed table on the system.
*
* The provided callback receives the information about each table in the
* 'info' pointer. A table may be mapped by client code if needed via
* uacpi_table_get_by_index().
*
* Note that this is a low level helper that iterates _every_ installed table,
* even tables that are unreachable via uacpi_table_find() etc. due to bad
* checksum.
*/
uacpi_status uacpi_for_each_table(
uacpi_table_iteration_callback, void *user
);
/*
* Retrieve information about the table installed internally at 'idx'.
*
* The number of available tables can be retrieved via uacpi_table_count().
*/
uacpi_status uacpi_table_info_get_by_index(
uacpi_size idx, uacpi_table_info *out_info
);
Oh yeah I forgot about the phys address in the info struct
union {
/**
* The physical address of this table, only applicable for
* UACPI_TABLE_ORIGIN_*_PHYSICAL.
*/
uacpi_phys_addr phys_addr;
/**
* The virtual address of this table, only applicable for
* UACPI_TABLE_ORIGIN_*_VIRTUAL.
*
* NOTE: use uacpi_table_get_by_index() if you need a virtual address
* for a UACPI_TABLE_ORIGIN_*_PHYSICAL table in order to map it.
*/
void *virt_addr;
};
Bro are u fucking kidding me
there's an ACPICA compiler regression in macos-latest
it cant compile some of my tests anymore
uACPI aml compiler when 
naah
Is it fine if I PR adding WAET and SPCR tables to uACPI?
https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/serial-port-console-redirection-table
http://download.microsoft.com/download/7/E/7/7E7662CF-CBEA-470B-A97E-CE7CE0D98DC2/WAET.docx
yeah ofc
Microsoft talks about patents something something
patent for a C struct?
Who knows
spcr is already in uacpi
Yeah, I've just noticed, but there is no ACPI_SPCR_SIGNATURE
feel free to add
@calm latch thanks, the patches look good to me, i'll have to unfuck the acpica regression before i can merge them tho
ok
ill check how to install a specific version of a package for brew
(hoping it's not yet in apt & choco)
give it a shot 
free labor when
I will make every tool uACPI requires until uACPI is completely dependent on me...
the documentation was just the start
damn
but yeah not depending on the acpica compiler would be cool
because the maintainer there just accepts random bs and they have 0 regression testing
they dont even have CI
if i had more time id do it
in rust or something since parsing is easier with its types
about uacpi_kernel_install_interrupt_handler,
- what polarity and trigger is expected for the irq?
- dumb question, but it's safe to assume it's a GSI, right? (not a PIC IRQ that possibly needs to be translated to an IOAPIC IRQ using the overrides)
wdym polarity?
active high/low
why does this matter here?
because the interrupt controller cares about how the irq is going to be asserted
i always left it default, i didn't even know it could do that XD
if uacpi_kernel_install_interrupt_handler is only used to install the SCI then it would be a good idea if it is specified in the docstring above that it should be configured as an active low level irq
I think you're supposed to use the interrupt source override structures in the madt as well, but yeah it should specify the defaults in the docstring probs
yeah, i just checked the acpi documentation and i have to check the overrides

for future reference
yep
SCI is just a normal ISA interrupt
but has different defaults for polarity/triggering
yes
It's an ISA interrupt iirc
impressive how on the leaderboard the top scores are 10M ops/s
meanwhile i have 100k/s ๐
keep in mind that the top of the leaderboard does not support multi threading though
iirc for loop byte copy memcpy won over PhD memcpy with LTO and O3
Aka the uacpi built-in
It also used SIMD
Since its in Userspace
memcpy calls probably got optimised out completely for smaller copies
it (= bytewise copy) did win for uacpi on menix but it was way worse in the actual memcpy benchmark
because uacpi copies are probably so small that the loop unrolling is not worth it
Probably
It's kinda sad there probably won't be a Nyaux moment again with all of the gen ai stuff
i realized why it wasn't being so quick, i was compiling with Og rather than, for example, O3
however now i have random ub all over the place ๐ข
hmm, maybe i added the Og flag later and forgot about it, with it i have 600k ops/s
now i have to fix the issues with O3
still, uacpi is pretty nice so thanks to all who contributed to its development
i cant wait to call random aml methods of my laptop and get random data sync flood errors
thanks
it was basically just me, some people contributed new tables, monkuous contributed openwatcom support and rewrote tests in C
first disappoinment of the day: my laptop does not have the fixed power button event
you're in for a treat yes
fixed power button is PC only
laptops have 3 different ways of routing the power button
- via the EC driver + AML Notify
- via the AMD GPIO driver + AML Notify
- via legacy general purpose event + AML Notify
amd gpio?
@calm latch has an impl in his kernel if u wanna take a look
all modern amd hw uses that
both ec and amd gpio are relatively easy to implement, and the legacy routing is free
you just have to hook a notify on the power button object in aml
i see
legacy routing is pretty rare tbh lol, i've only seen one laptop like that, it's some toshiba that monkuous has
most are just EC
i had a 2016 laptop which supported it
Desktops use it?
desktops are usually fixed event
so basically just hardcode whatever ec your laptop has its fine 
clanker, implement the power button event on my laptop
hardcode whatever register the firmware uses internally to check a pending pwrbtn press
cros_ec isnt that hard anyway
and you can claim that implementing that is a "real" driver
For anyone curious this is how general purpose event dispatch loop looks like on monkuous' toshiba laptop:
While ((GP50 || (GP51 || (GP52 || (GP53 || (GP54 || (
GP55 || (GP56 || (GP57 || (GP60 || (GP61 || (GP62 || (GP63 ||
(GP66 || (GP67 || (GP70 || (GP71 || (GP93 || (GP94 || (
GPAP || (GPBP || (GPCP || (GPDP || (GPEP || (GPFP || (GPGP ||
(GPHP || (FCDP || (FTVP || (FQSP || (GP96 || (GP97 || (
GPD0 || (GPD1 || (GPD2 || (GPD3 || (GPD4 || (BPFE || (TPBP ||
(ECDS || (B1ST || B2ST)))))))))))))))))))))))))))))))))))))))))
jesus
All of these are recursive as well
lmao of course
So it's OrOp(GP50, OrOp(...
the "worst" I've seen is
return 0xFFFFFFFE
return 0xFFFFFFFE
and my laptop has like 5 or 6 objects that are missing
acpica complains too
this is just crappy fw patching
Wasn't this on oberrow's laptop?
nope
oh dear god
wait haiku is back??
yo????
they updated the PR and it seems to actually work now + using latest uacpi https://review.haiku-os.org/c/haiku/+/8937
they're using some very niche apis and in general haiku is way more advanced acpi-usage-wise
than any other hobby os i've seen
or i guess its not even that hobby at that point since they have funding etc
yo nice
which niche apis out of curiosity?
ah neat
Looks like no one in ACPICA cares about the regression
ill have to bisect the damn compiler myself
rip
Bisecting: 61 revisions left to test after this (roughly 6 steps)
[b35adf49e89a610ea9ea33af21c1970ea95f56e4] Add validation for Node in AcpiNsBuildNormalizedPath to prevent use-after-free vulnerabilities
Not too bad
yeah that aint bad tbh
alright
eff423cadbe44c916078d99b666406b20aea130b is the first bad commit
commit eff423cadbe44c916078d99b666406b20aea130b
Author: ikaros <[email protected]>
Date: Sat Jan 10 20:39:57 2026 +0800
Add AslKeywordMappingCount for validation in OpcGenerateAmlOpcode
Fixes: #1070
Signed-off-by: ikaros <[email protected]>
source/compiler/aslglobal.h | 1 +
source/compiler/aslmap.c | 2 ++
source/compiler/aslopcodes.c | 8 ++++++++
3 files changed, 11 insertions(+)
bisect found first bad commit
Stupid choco and brew always hardcode the newest version and u cant fetch older
so I'll disable MacOS CI completely, and for Windows I'll download an older release manually from the intel website in CI directly
and linux will keep working since ubuntu is using an old version thankfully
@calm latch could u please rebase your pr so it's on top of master? I added a fix for CI
done
same for DBG2 iirc
all the microsoft tables are shipped that way
yknow part of me wonders if those table docs all being word docs isnt some sort of licensing policy thing dating back to when pdfs were pay-to-create
all you need is a really really bad allocator to make that number slow
pretty sure that uacpi has a pattern of tons of tiny allocations and deallocations during that init process
it's likely O(n) during free
I have two allocators, a base one that is really really simple and slow as a snail riding an elephant on the back of a tortoise, and then a buddy allocator which is really fast, subsystems allocate buddy allocators inside arenas in the dumb allocator, and uacpi has such a buddy region
it is also slow if you're using tcg for obvious reasons
here's mine on KVM
[0]: [uACPI] successfully loaded 1 AML blob, 1757 ops in 3ms (avg 536526/s)
feel free to take a look at my allocator if you want, basically uacpi only really does 3 things during init, requests memory, io space and an interrupt
if you give uacpi a bump allocator you can fudge that stat lol
yeah it allocates very small amounts
does it also release that memory after?
or some is kept
it keeps some iirc
because it sets up interrupt handlers and will need memory to handle that
if you stub out it's interrupt registration function in your abstraction layer you can safely tear down uacpi afterwards by taking away it's allocated memory region, I used to do that
Thats a common misconception btw
Uacpi scored pretty poorly on that test with a bump allocator
Since it made the cache cold and as u said uacpi frees and allocates tiny objects all the time
An allocator that reuses memory scores a lot more here
If only there was uacpi_state_reset that cleanly tears everything down lol
But it literally builds an entire aml namespace lol
Only temporary objects are freed
Whatever was used during DSDT eval
maybe i should consider making like an emulated arena allocator in uacpi
or like an object cache for fast reuse
are these memory map requests or io space requests?
99% of kernels can just stub out io space requests,.it's asking for access to an io port and most kernels don't restrict that unless you're doing some kind of microkernel thing
yeah it's io map i tought i left the allocation debug on
do you have a way to generate profiler dumps e.g. callgrind.out
you might want to add that so you can profile your kernel and see where the expensive parts are
this is a violently incorrect way to go about mapping I/O
on x86 its not
its for port io
yeah lol
map_memory is for mapping memory
i guess the names could be clearer but they're designed after their respective name in the acpi spec
aka SystemIO and SystemMemory
well there's a comment there i guess
i do
I'm betting debug output is the most expensive part of that?
no
or well
i can't see the print functions
they would polute too much
how can you not see them? you exclude them from profiling?
How do you do that
hmmm thats why you cant profile debug output
the ouput format isnt flexible enough
i recommend outputting it in callgrind format on e.g. com1 or the qemu console
then, loading that into kcachegrind
if you want i have code for that
oh yes pls
its just a simple text format a bit like yaml
you do need to store 'edges'
mine stores it to a simple hash table
then just walks the hash table when i press a debug-key (ctrl-alt-shift-P)
thx

