#uACPI - a portable and easy-to-integrate ACPI implementation
1 messages · Page 10 of 1
Which
Name (_ADR, 0x00140000)```
Yeah see if 14:00:0 is your xHCI
I have a INT3420
So maybe u do put them into d3 via acpi as well even for pci, idk man
intel bluetooth rf kill
What is that
this
On that pc if u do lspci you will see xhci at 14
00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)
indeed
Yup
Hopefully it doesn't kill you
Indeed
interestingly, it actually uses OSI here
Nothing interesting about that
They do osi to emulate backwards compat for old oses
wait
Or for non windows
it has an OSI linux
Its from 2013, so yes
I assume firmware devs were more considerate back then?
and not
"hello firmware dev"
"hello, I like money"
"why did you make this firmware?"
"money"
Thats because they do it on init and store the integer representation in a global variable
soon bios writers will be using _OSI("OBOS")
E.g. 3 would mean windows xp, 4 windows vista, etc
Then they just check that variable
so that's what OSYS means
Yup
you're funny
just magic numbers
interestingly, the linux constant is used in some other unrelated place
wait it's 1000 hex
Sleep (0x03E8)```
Workaround for some bug they had with it at the time probably
Makes sense
By default it does
aaaand my ahci driver broke
Its configurable
And u can tell it not to or tell it to report arbitrary stuff as supported
can I make obos an OSI string
waiting for the day obos becomes used world wide
Server hardware does queries for more obscure kernels
E.g HP-UX etc
Various supervisors
Hypervisors*
Indeed
then obos will be used for your everyday web server

or your router
then I become rich
and retire at the age of n
rare MS documentation W
@north holly this one is actually really deep
I will read it
Do it
it seems as if most of my devices might not actually be able to wake my system?
I checked the ps2 keyboard
and it didn't have neither S3D or S3W
only PRW
oh yeah
kinda like how on qwinci's thing
there was something to do with I2C
and PS2
If your motherboard actually had a ps2 port it would be wakable too
Ye
I'm just gonna quickly see what state the xHCI controller needs to be in
to wake me
_S3D is 2
PRW is 3 I think
S3W is NA
so I'd go into D state 2
but wait
I don't have _PS2
which must mean I missed a _S3W
but I didn't
To put a device into the ACPI power state Dx (where x is a number between 0 and 3 inclusive) the kernel is supposed to (1) enable the power resources required by the device in this state using their _ON control methods and (2) execute the _PSx control method defined for the device. In addition to that, if the device is going to be put into a low-power state (D1-D3) and is supposed to generate wakeup signals from that state, the _DSW (or _PSW, replaced with _DSW by ACPI 3.0) control method defined for it has to be executed before _PSx. Power resources that are not required by the device in the target power state and are not required any more by any other device should be disabled (by executing their _OFF control methods). If the current power state of the device is D3, it can only be put into D0 this way.
unrelated to the xHCI thing
but still useful
I honestly thought that suspend was gonna be a one or two day thing
now it technically was
but it doesn't work on real hw
therefore invalid
and is incorrect
Why do you think it breaks all the time and no one gets it right
idk if any hobby os except for crescent has suspend
I think I should keep a list of devices I put into a deeper sleep state
so I can wake them after wake
might solve the framebuffer problem if it exists on real hw
somehow
on my laptop it does make the screen go off and the power light too though then it wakes up after like a second or so, idk what exactly wakes it up tho (and I did at least try doing the proper wake device setup + making sure that all the other cpus are in a cli hlt loop)
and on my desktop at least I hear the psu click when it goes off and then it didn't wake until I pressed the power button (idk where exactly did it get at that point tho as the display was just blank and I didn't re-enable the sci irq yet so I could see if it responds to power button press by shutting it down)
I won't be surprised if it wants you to use it for random hardware workarounds
alright finally ready to merge
19 commits
getting closer and closer to 1.0
this is it as far as new features for 1.0 go, maybe i'll also do more eval shorthands
the rest is thread safety related stuff
so 1.0 means api freeze
ye
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C 19 3420 849 15713
C/C++ Header 46 1012 1399 5298
C++ 4 433 517 2655
Python 3 213 39 587
Markdown 1 59 0 190
CMake 3 25 14 119
YAML 1 10 5 57
Meson 1 2 0 23
-------------------------------------------------------------------------------
SUM: 78 5174 2823 24642
-------------------------------------------------------------------------------
Looks like we're nearing 25k, but i dont expect it to grow much beyond that. Maybe only because of new test cases or something
thread safety (which is the final large piece) shouldnt increase the loc by a lot
and L for cloc, imagine not knowing what ASL is
...back to this annoying branch I go
wait did the last acpica maintainer get laid off
i hope not
yeah they were really nice
possibly
lol wtf?
oh no oh no
how did u know this
i googled his name
this also came up on google
these people are obviously pissed off and probably wrote Intel to sack him
so what did he do exactly
Police released a video of the vandalism recorded on Oct. 2 at 6 p.m. near Kaiser Westside Hospital. In the video, the man appears to kick and yank on the car’s side mirror.
Shortly after noon on Friday, Hillsboro police arrested 32-year-old Saket Dumbre near NE Amberglen Parkway and NE Evergreen Parkway. He is charged with first-degree criminal mischief for damaging the car, a Corvette.
god he really went for that mirror
well there you go
what the fuck
now you can write to Intel and ask if they'll get you a green card to take over
id be down
like this is comical
what are the odds
that this happens to be this one and only acpica maintainer
i wonder what pissed him off so much
poorly parked car?
looks satisfactory to me
i don't know what americans think good parking looks like though
the aml madness got to him
lool
yes, probably the most likely conclusion
it's only a matter of time till it gets you too @fiery turtle
I tell you this shi is cursed
acpica maintaier after i open 99999 issues about nt incompatibility or various segfaults
he was burnt out from maintaining acpica alone and lashed out at a corvette
I can't imagine having to maintain something as vital as acpica alone though
that's actually awful
acpica actually doesnt get updates
so there isnt much to maintain
he was just laizily reviewing a few prs once a few weeks
in fairness it looks like linux is just doing their thing
they did the usual thing and stole the acpica code and put it into the linux tree at some point, reformatted and restyled it, and now work on it themselves
but yeah you would expect it to be a vital critical component
but its just this one guy
sounds fucked either way
well there is the uefi board too
and I think there are regular meeting there
i was promised a chance to maybe get a seat there at one point
the cursed linuxize.sh script
yeah especially with me pinging you every 0.02 seconds while I'm implementing suspend
I now test suspend on real hw
did u actually implement d states
what did u implement
Only difference that matters is that now I call PSW
yea...
any news
It no work
F
what a read lol
if he was gonna be arrested might as well kick it harder
make it worth
crime is the same
the implementors board or whatever?
i have a friend who's technically a member (licensees of UEFI or whatever are members apparently but idk much about how that works
they don't get to vote tho
basically yes, people from all companies like intel, lenovo etc
aren't they all based on one or few efi implementations? like from intel or something
by they i mean efi firmware that vendors like asus or lenovo ship
it would be kinda silly for everyone to make their own efi implementations
but i guess you gotta spend the shareholder money somehow
wasting it on buggy firmware is one way of course
yeah but the uefi board also does acpi, and thats different per mb
and well they work on new features and stuff
There are two modern bios vendors (companies selling bios as a product) I can think of, AMI and Insyde (historically also phoenix and Award), today I think both are based on edk2, but oems still have custom stuff like HP, Lenovo and Microsoft
With Microsoft the main selling point being written in Rust iirc
Currently solving various thread safety puzzles like: if i dont lock here can this get copyobject'ed into under my feet
this is the main way for internal code to protect against copyobject
uacpi_object *uacpi_namespace_node_acquire_object(
const uacpi_namespace_node *node
)
{
uacpi_status ret;
uacpi_object *obj;
ret = uacpi_namespace_read_lock();
if (uacpi_unlikely_error(ret))
return UACPI_NULL;
obj = uacpi_namespace_node_get_object(node);
uacpi_object_ref(obj);
uacpi_namespace_read_unlock();
return obj;
}
and for user api there is no way to access the object at the node, only by deep copying it via uacpi_eval
doubt
Well the smp trampoline worked
So I thought that it should obviously work when reused
obviously 
/*
* These are stored here to protect against stuff like:
* - CopyObject(JUNK, \)
* - CopyObject(JUNK, \_GL)
*/
uacpi_object *global_lock_object;
uacpi_object *root_object;
i now store \ and _GL objects in the global uacpi context
first of all so i can protect against CopyObject, but also so that i dont have to race against them with AML and always have direct access where needed
#3 0xffffffff800095da in uacpi_kernel_free (mem=0x0, size_hint=0) at ../../kernel/io/uacpi.c:199
#4 0xffffffff80019792 in item_array_clear (arr=0xffffc80000030098) at ../../vendor/uacpi/source/interpreter.c:49
normal?
frees of null are pretty normal yeah, uacpi does them all the time
is this causing some trouble?
no, i just couldn't remember if it was expected or not
uacpi is getting a more prominent position in keyronex in the future (the testbed kernel is getting a parallel tree of ACPI namespace nodes that the OS tree of devices associate themselves with) and the integration is new code
i see, i could catch it at call site to cause less confusion for people ofc, but its generally pretty common to free NULL in C land i think
nice!
the docs above uacpI_kernel_free mention frees of null being a no-op i think
Method (TEST) {
OperationRegion(MYRE, SystemMemory, 0, 128)
Field (MYRE, AnyAcc, NoLock) {
FILD, 32
}
FILD = 1
Return (RefOf(FILD))
}
Name (X, "")
Local0 = TEST()
CopyObject(DerefOf(Local0), X)
Debug = X
@mortal yoke new cursed test case dropped
This is expected to read from the MYRE operation region and return the previously written 1
uACPI wont pass it at this moment, but im in the process of making it do that
let me know what qacpi thinks
time to test it ig 
i discover new cursed shit u can do with aml every day
making it pass unfortunately means that u can make an infinite chain of object -> ns node -> object -> ns node -> object
so either i add code to do it non recursively or i have to live with the fact that its possible to stack overflow uacpi
atm it does reference the namespace node, but it's marked as dangling and doesnt have an object backing it
so u cant read from this field
it kinda works on qacpi, the opregion does reference a dangling namespace node but its not necessary to read from the op region
there are more field problems tho, ig its supposed to read the field when you deref it?
Debug = X is supposed to print 1
Aka yeah it must actually read via MYRE
when u deref u just get a field object
u dont read it ofc
ah yeah
in this case X becomes the new FIDL container
so its likely only an issue with my poor debug print lol
so like it does actually do the read via MYRE and stuff?
yes
how would that work, I kinda want to try doing that lol
im trying to come up with a test case
or actually would that only happen if the namespace node is not destroyed at the end of the method?
Method (FOO, 1) {
OperationRegion(MYRE, SystemMemory, 0, 128)
Field (MYRE, AnyAcc, NoLock) {
FILD, 32
}
CopyObject(DerefOf(Arg0), MYRE)
Return (RefOf(FILD))
}
Method (BAR) {
OperationRegion(MYRE, SystemMemory, 0, 128)
Field (MYRE, AnyAcc, NoLock) {
FILD, 32
}
Return (FOO(RefOf(FILD)))
}
Method (TEST) {
Name (X, "")
Local0 = 100000
Local1 = BAR()
CopyObject(DerefOf(Local1), X)
While (Local0--) {
CopyObject(0, Local1)
Local1 = FOO(RefOf(X))
CopyObject(DerefOf(Local1), X)
}
}
TEST()
maybe something like that? idk i havent tested
it should make a chain of field -> opregion -> field -> opregion -> field -> opregion
Or rather, in the end it will be a field -> field -> field -> field -> field
so if u keep all of those references alive at the end you will recursively delete all of them
which should stack overflow
yeah i think this should work
it overwrites the opregion referenced by a field to also be a field
So iin the end the X object should be a chain of 10000 fields and an opregion at the end
its an integer for some reason
u probably read from the field somewhere where u shouldnt
I think the local ref is getting destroyed somewhere and then it does a store with an implicit conversion
its copyobject but idk how do I actually fix that without breaking other stuff (that the tests test), looks like it does indeed cause a stack overflow with that field code tho
hmm, how does it stack overflow if u said u deref the field?
after I tried to fix it
ah
but yeah u should probably fix it, because there shouldnt be any reads happening during DerefOf
yeah, I think the same issue also occurs if you do stuff like ```
CopyObject(0, Local0)
Local0 = "abc"
Debug = Local0
on local op it returns a special local reference stored within the actual local object (within the method frame) and then in copyobject it overwrites the local reference stored within the method frame so then any of the other code doesn't know its a local anymore
so then it does implicit conversion in the second store in the example I posted because it just sees Local0 as a normal integer object
saket dumbnre's github account is now gone
waaait
oh no, he just renamed it
your CopyObject actually modifies the object itself?
the object data yes
yeah i did that initially and it caused soo many problems
objects in uacpi are now immutable
i just do object_replace_child in CopyObject
so the object referenced by Local0 is replaced, not the Local0 itself
this also means u must have a per-object mutex if u want to use it anywhere other than the interpreter
because it can get copyobject'ed into at any point in time
oh yeah
whereas in my object model i can just do
lock()
obj = node->obj
ref(obj)
unlock()
and im guaranteed that this object will remain the same
the only difference is e.g. if it's a string it can be modified via Index etc
but that wont cause a crash or anything
ffff9a0d5c7576ec: Method(TEST,0x0)
ffff9a0d5c757716: Name(X___,"")
ffff9a0d5c75771d: Store(TEST()
ffff9a0d5c780aea: {
ffff9a0d5c780aea: OperationRegion(MYRE,0x0,Zero,0x80)
ffff9a0d5c780af4: Field(MYRE,0x0)
ffff9a0d5c780afc: {
ffff9a0d5c780b01: FILD,32
ffff9a0d5c780b01: }
ffff9a0d5c780b01: Store(One,FILD)=0x1
ffff9a0d5c780b07: Return(RefOf(FILD)=<Obj=FFFF9A0D5C780BD0,Type=ObjAlias,Value=0xffff9a0d5c780de0,Buff=0000000000000000,Len=0>)
ffff9a0d5c780b0d: },Local0)=<Obj=FFFF9A0D5BBF2090,Type=ObjAlias,Value=0xffff9a0d5c780de0,Buff=0000000000000000,Len=0>
ffff9a0d5c757723: CopyObject(DerefOf(Local0=<Obj=FFFF9A0D5C77C430,Type=ObjAlias,Value=0xffff9a0d5c780de0,Buff=0000000000000000,Len=0>)=<Obj=FFFF9A0D5C75E238,Type=Unknown,Value=0x0,Buff=0000000000000000,Len=0>=<Obj=FFFF9A0D5C75E238,Type=Unknown,Value=0x0,Buff=0000000000000000,Len=0>,X___)=<Obj=FFFF9A0D5BBF2090,Type=Unknown,Value=0x0,Buff=0000000000000000,Len=0>
ffff9a0d5c75772a: Store(X___=<Obj=FFFF9A0D5C75E238,Type=Unknown,Value=0x0,Buff=0000000000000000,Len=0>,Debug)Unknown()
=<Obj=FFFF9A0D5BBF2090,Type=Unknown,Value=0x0,Buff=0000000000000000,Len=0>
Method (TEST) {
OperationRegion(MYRE, SystemMemory, 0, 128)
Field (MYRE, AnyAcc, NoLock) {
FILD, 32
}
FILD = 1
Return (RefOf(FILD))
}
Name (X, "")
Local0 = TEST()
CopyObject(DerefOf(Local0), X)
Debug = X
Looks like this test case causes a use-after-free in NT
because it thinks that Type=Unknown
so honestly fuck it, ill just keep the current behavior where the object stored at the node is deleted at the same time when the node is uninstalled
ill make sure that reads from this field will just abort execution instead of uaf
is that just invalid aml? or should this work?
the spec doesnt tell us if its valid or not
it returns a reference to a local object outside of the method
that's interesting
ACPI Error: Invalid descriptor 00635960 [Cached Object] (20220331/exresop-392) UAF in ACPICA as well
yeah I guess nobody does that in practice if it doesn't even work on NT
so annoying that we don't know what its supposed to do officially
and in general it says nothing about lifetimes
whether objects are allowed to escape the method where they're created
ig Ill keep it in qacpi tho because idk how would I make it not work lol (and I did fix the copyobject issue, though it still copies the inner data to named objects but I left handling that for an another time because its more annoying and requires changes to stores as well and I'd rather not touch that code if I don't have to)
well the way i do it is when a namespace node is uninstalled it just does node->obj = null; node->flags |= DANGLING_NODE;
and so when that field tries to access the opregion it aborts
and the node is deleted when its refcount drops to 0
so u currently pass that test and also stack overflow on that other test?
yes
I guess one possible fix for the overflow would be to make object destruction iterative but that's kinda annoying especially in c++
for packages i just make a queue of objects to unref
and then when unrefing an object from a queue that might add even more objects to the queue
if its a nested package
i think this would work for this case too
yeah it probably would
uACPI thread safety has been excruciatingly painful
well for the most part because i have to resolve a few design issues to get there
currently banging my head against opregion handlers
since those need to have an opregion node reference, and also have the ability to run _REG, and also be able to be invoked from the interpreter, aka write-locked namespace context, but also unlocked for the duration of the client handler runtime
basically i have to be insanely careful to not cause a deadlock between subsystems
e.g.
thread0: thread1:
namespace_write_lock() opregion_lock()
opregion_lock(); to dispatch field r/w namespace_write_lock() to run _REG
what also makes the issue harder, is installing an opregion handler is done at device level
and then the installation recurses downwards and is applied to every opregion below
so it must run an arbitrary number of _REG methods
ig i have to queue them up to be run, and then run them once opregon_lock is released
Phoenix is still kicking
Oh that message is old oops lol
Evening 
Or afternoon
Getting close to make a draft PR for the new ACPI driver
Want me to add you to the discussion when I open it :)
It’ll probably get a little bit argument fair warning
i could point out any api usage errors maybe if i spot any
yeah i mean
thats probably expected
Really improved things when hooked up together with my WDDM work though
Can actually use interrupts with WDDM drivers properly now
Wow
Infy is based
Really based!
no ur based
No u
Is your fork already viewable?
locking really is one of the hellish problems
probably the area in which i have had to develop the most to carry out keyronex properly
nooo i believed in your allocator
Skill issue
uacpi issue of course 
qemu
so it's most likely the allocator?
probably yes, because on namespace load it allocates quite a lot
didnt u have it working before
I don't really know tbh. I just didn't like the old one very much, plus I want to redesign some things and copy less code lol
and c++ modules
how did it not break before in your last kernel lol
it was fine in the previous one :D
I just experienced a brief skill issue while rewriting it
does uacpi append \n to log messages
seems like it does
ye
mutex
?
your mutex helpers
i mean just add printfs and see where you're returning this
those methods are serialized so it tries to acquire the mutex
What actually needs to run concurrently? The performance of what is improved?
context?
in general: any sort of driver initialization that binds to aml objects (so a lot of them), AML handlers, runtime GPE stuff, EC stuff
a lot of things
The context is your work on uACPI thread safety
I just realized I have no clue why it would be useful
because things might run in different threads
Well, yeah, but unless you ran them a lot or just generally cared about their performance, a big lock would be enough
a big lock sounds like a big L
(it is)
So is needless work, so I wondered why it is needed
because people like W s and not L s
well as i mentioned, a lot of aml is called both at runtime and during initialization. a lot of uacpi api is used not directly related to aml for all of those things too
so it is definitely not needless work
I assumed it was needed, didn't mean to offend, I just realized I personally didn't know why
none taken, fair question
cool
I was struggling with some thread safety stuff as always
Essentially if u use just the namespace write lock it must be released for the duration of the user opregion handler, and during that window if the user calls uninstall_address_space_handler there's basically a race condition with the handler being uninstalled while it's being dispatched to etc
I was like how does ACPICA solve it
They should've had a similar problem right
Well
It doesnt solve it at all
It just lets the code crash in this case
big brain library
I like how any edge case i come up with ACPICA just straight up doesnt give a shit
am i being too pedantic or something idk
if (AcpiNsIsLocked)
{
Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (Status))
{
return_VOID;
}
}
/* Now stop region accesses by executing the _REG method */
Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_DISCONNECT);
if (ACPI_FAILURE (Status))
{
ACPI_EXCEPTION ((AE_INFO, Status, "from region _REG, [%s]",
AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
}
if (AcpiNsIsLocked)
{
Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
if (ACPI_FAILURE (Status))
{
return_VOID;
}
}
like
no u can't just release the goddamn lock
oh i also found a bug in their opregion cleanup code
it calls ReleaseMutex instead of DeleteMutex
i guess i should fix it while im at it anyway lol
but SaketDumbre might not be able to accept it
I wonder what happens if you compile acpica with asan
actually based
wait im actually brain damanged
i just spent an hour inventing a solution for a problem i didnt have
anyways that hour was wasted but at least now i know i was doing redundant work in one place
I invented a special queue to queue _REG methods to run at a later point with mutex released
but i literally didnt need to do that because i was doing uacpi_reg_all_opregions at the bottom anyway and it just rescans the namespace and runs _REG where needed and doesnt need a special queue to do that
so not only did i not need to do this, i also came up with a dumb overcomplicated solution
/*
* Returns UACPI_TRUE via 'out' if the type of the object stored at the
* namespace node matches any of the type bits in the provided value,
* UACPI_FALSE otherwise.
*
* NOTE: due to the existance of the CopyObject operator in AML, the
* return value of this function is subject to TOCTOU bugs.
*/
uacpi_status uacpi_namespace_node_is_one_of(
const uacpi_namespace_node *node, uacpi_u32 type_mask, uacpi_bool *out
);
also added stuff like this
Alright, about that ACPICA bug
Will see if Saket is able review it
I even searched through the history and blames to figure out how they did this bogus stuff
looks like this bug is present in the Linux kernel as well, so ill send it there as well when the patch is accepted into acpica
on an unrelated note, they were leaking an entire mutex object for each opregion for 6 months and no one noticed
imagine not having any tests for this
lmao
Hows uacpi thread safety going you may ask...
currently passing all tests, but still basically incorrect for all edge cases
interpreter, notify handlers, opregion handlers, namespace and stuff should be thread safe
the event subsystem is the last non thread safe one atm
still a lot of polish to do before this is even remotely mergeable
also i have 11 commits where the last one is a giant patch bomb
which is something i try to avoid
also uacpi_namespace_for_each_node_depth_first is now:
uacpi_namespace_for_each_child_depth_firstuacpi_namespace_for_each_child_depth_first_typed
where the typed helper accepts a bit mask of the types u care about
also i just realized i dont have any public api for checking if the current node is an alias lmao
the amount of TOCTOU bugs in ACPICA is insane
yes those are difficult to trigger in real world but like
idk man
basically everything related to uninstalling any sort of handlers
which is not really done that much
why do you even bother trying to fix ACPICA?
nah its more like
i have this race condition, how do I protect against it
ACPICA must have had a similar problem, lets see how they did it
look inside: they did nothing
lol
i do fix stuff if i notice low hanging fruit or completely bogus shit
but race conditions like this are not trivial to fix so i wont bother ofc
Thinking whether i should add a namespace_for_each_child with a max depth parameter, like ACPICA
Looked at the existing ~80 usages in the linux kernel
- 80% is just UNIT32_MAX
- 15% is 1
- 4% is clearly bogus limits like 32 (where did they come up with those??)
- 1% is 2
still not sure but maybe ill still add it as a separate helper
u can currently emulate it in uacpi by just doing if (namespace_node_depth(node) == X) return NEXT_PEER
/*
* Depth-first iterate the namespace starting at the first child of 'parent'.
*
* The extended helper allows limiting the iteration depth with 'max_depth'
* while also performing node filtering based on the 'type_mask'.
*
* uacpi_namespace_for_each_child_simple is equivalent to:
* uacpi_namespace_for_each_child(..., UACPI_OBJECT_ANY_BIT, UACPI_DEPTH_ANY)
*/
uacpi_status uacpi_namespace_for_each_child_simple(
uacpi_namespace_node *parent, uacpi_iteration_callback callback, void *user
);
uacpi_status uacpi_namespace_for_each_child(
uacpi_namespace_node *parent, uacpi_iteration_callback callback, void *user,
uacpi_object_type_bits type_mask, uacpi_u32 max_depth
);
whatever this is what it's gonna look like now
hmm fuck
ACPICA also has a way to specify ascending_callback
its used by linux only to offline busses upwards from child to parent
alright im going to add the goddamn ascending callback as well lmao
lets break every user api in existance
pls vote: #polls message
imo returning an enum like they do now is fine, if they would return status then it might be confusing where a particular status is coming from (as in whether it was an error while iterating or if it was an error returned by the user from the callback)
idk if its really a problem in practice though
yeah i agree on that point
the only reason im considering this is there are like 5 different enums right now for this
i made the internal node find helper more verbose since thread safety and stuff
ret = uacpi_namespace_node_resolve(
node->parent, "_REG", UACPI_SHOULD_LOCK_NO,
UACPI_MAY_SEARCH_ABOVE_PARENT_NO, UACPI_PERMANENT_ONLY_NO, ®_node
);
now every call is like this lmao
same goes for namespace iteration:
uacpi_namespace_do_for_each_child(
device_node, do_run_reg, UACPI_NULL,
UACPI_OBJECT_OPERATION_REGION_BIT, UACPI_MAX_DEPTH_ANY,
UACPI_SHOULD_LOCK_NO, UACPI_PERMANENT_ONLY_YES, &ctx
);
that's indeed a lot of enums lol
well thats unrelated to that poll but yeah
i just dont like booleans as function parameters
when using enums like this its very hard to make a mistake and when u look at the call site u instantly know whats going on
@mortal yoke this works for u right?
// Name: CopyObject to predefined works
// Expect: str => HelloWorld
DefinitionBlock ("x.aml", "SSDT", 1, "uTEST", "TESTTABL", 0xF0F0F0F0)
{
Method (HELO) {
Return ("Hello")
}
Method (WRLD) {
return ("World")
}
Method (MAIN) {
CopyObject(HELO, \)
CopyObject(WRLD, _GL)
Return (Concatenate(\(), _GL()))
}
}
yes
I should implement that
yes!
the test should probably be extended to attempt to write to a locked field after this copyobject
also I found a funny field bug while I were implementing reads for fields > 8 bytes, I were using a 32-bit mask while reading the field so for a >= 8-byte field using 8-byte access size would cause a shift overflow
idk what I were thinking when I used an uint32_t there
this passes for ACPICA also
BUT
// Name: CopyObject to predefined works
// Expect: str => HelloWorld
DefinitionBlock ("x.aml", "SSDT", 1, "uTEST", "TESTTABL", 0xF0F0F0F0)
{
Method (HELO) {
Return ("Hello")
}
Method (WRLD) {
Return ("World")
}
Method (MAIN) {
OperationRegion(NVSM, SystemMemory, 0x100000, 128)
Field (NVSM, ByteAcc, Lock, WriteAsZeros) {
FILD, 8,
}
FILD = 0xFF
CopyObject(HELO, \)
CopyObject(WRLD, _GL)
If (FILD != 0xFF) {
Return ("Locked field read-back failed")
}
Return (Concatenate(\(), _GL()))
}
}
I made a slightly more complex version of the test
ACPICA:
ACPI Error: AE_BAD_PARAMETER, Could not acquire Global Lock (20200925/exutils-248)
ACPI Exec: Segmentation Fault
they really dont care about anything do they 
Yeah don't do that unless it's like doX
Updated comparison vs ACPICA in the readme
lemme know what u think
also added this example lol
should i test uACPI on my new Arrow Lake PC? :^)
Btw is the "bug" with 0 byte allocs fixed
well now u know for sure
until I forget again
Lovely
i'm less keen
it's not the end of the world either way
so far almost a tie
i voted
EVERYONE VOTE ENUM CALLBACK
did u even use this api lol
yes
what for?
i use uacpi, as for the api no i dont use it in nyaux BUTTTTT i might use it soon :)
and I
like
enum callbacks
well looks like they're here to stay
damn goverment ignoring infys prs 😡
#down with acpica
acpica is making the frogs acpi error
didnt the maintainer get arrested or smth?
That makes acpica unmaintained, no
Another acpi lib bites the dust
For now, I don't imagine it's a situation everyone's comfortable with if it's true
Perfect time to add an acpica compat layer to uacpi and get it mainlined 
Lmao
Well they still have GitHub activity
Like starring random repos
So I imagine not
He'll be on bail
Probably won't get a life term without parole just for smashing a corvette
u mean vacation 
can't blame anyone for doing that
ugly shit car
Okay so
the poll looks like people like the enum values
but ill still generalize the enum to just uacpi_iteration_decision, it can be reused for everything, with an extra UACPI_ITERATION_DECISION_NEXT_PEER specific to namespace iteration
keep yourself safe
I also deretardefied my uacpi_kernel_get_ticks kernel api, it's now called uacpi_kernel_get_nanoseconds_since_boot and returns a regular nanosecond counter instead of 100ns ticks
i handle the conversion to 100ns ticks where needed internally
should be harder to make mistakes in api implementations
This is the stuff I do for that, kinda retarded https://github.com/OBOS-dev/obos/blob/userspace-work/src%2FuACPI%2Fkernel_api.c#L321-L332
yeah i guess u dont have to now
[uACPI][INFO] successfully loaded & executed 1 AML blob in 533ms
[uACPI][INFO] namespace initialization done in 8ms: 188 devices, 0 thermal zones
Would u guys like it if i added these in Xms into the log?
Sure
i kinda also want to add how many opcodes and the total bytecode bytes executed lol
maybe thats going a bit too far
ill see if someone else says their thoughts on this
More useless stats that have no performance
personally i enjoy seeing metrics like this but overall they're useless and just add extra noise to the log
Just add config options for it
Obos at the end of initing the kernel
Says all vmm stats
The line wraps cause of how much
It has committed memory, pageable memory, non-pageable memory, memory paged out, uncommitted memory, amount of page faults, amount of soft page faults, amount of hard page faults, amount of page faults since the last paging interval, amount of soft page faults since the last paging interval, and amount of hard page faults since the last paging interval
Also physical memory usage
So all of these
yes
Me too, maybe hide all the additional stats behind a more verbose log level so it's opt in?
hows this 
[uACPI][INFO] successfully loaded & executed 1 AML blob in 826ms (9192 opcodes, avg 11116 ops/s)
(this is slow because its using O0 + asan + ubsan + builtin uacpi libc which is slow af)
ngl i like these stats
maybe needs to be less verbose somehow
even if its not that useful its always fun to see metrics like that
what's the average time in a kernel?
no idea, this is on a very wip PR branch
depends on how advanced the kernel is
its very libc + allocator bound id imagine
also test runner records every uacpi allocation in a hash table which doesnt help lmao
i guess if i merge this people would be able to brag about how fast their kernel is
inb4 nyaux 1 op per second
(jk nyaux pls dont get offended)
uacpi is now a stress and performance test 😆
lol
lmao
Very satisfying to read
Its not all that practical, but I like seeing those kind of stats
Or more generally interrupts/sec, kernel vm/pm memory usage.
in some sense it is a good benchmark because it uses like most critical kernel infra, like vmm, slab, mutexes, io, stuff like that
yeah
io isn't really tested that much tho
Literally just port io and mmio
I like that
@fiery turtle my time is now synced with Moscow time
So now I will tell you to go to sleep since it's 12am
are u in turkey
Now I know full well I'm not going to sleep for another couple hours
on pilgrimage?
are u back from vacation?
22nd I go back
i see
Then I'm back on obos grind
whats next for obos
#1141057599584878645 message
glgl
Thanks
Although before mlibc, I might port to esp32
We'll see how that goes
it doesnt even have an mmu
It haves something resembling one
SHOULD be good enough
If that doesn't work it's riscv port
Risc v 64 because I quite like 64 bit arches
Or maybe even both
And if I decide riscv is yuck
I do i386
be ahead of fadanoid and do ppc64le
I feel like by the time I get to porting fadanoid would've started
Because I have a hell lot of syscalls to implement
And I'm gonna needa implement TTYs
I expect that all to be mid December at the earliest
m68k took a week to port
So I assume most other ports should take around the same time
i'll source a powerpc box at some point
it might be a powermac g5 though (affordable and generally of good quality) and that's big endian
is it forced to be BE or can you toggle it
in principle supporting open firmware on a powermac g5 should be a great leap towards supporting the linux version of device trees
you know, i thought forced, but i also know that windows/ppc was little-endian
i'd guess you can switch but in LE you lose access to openfw
he was forced to use big endian <insert gif>
apparently not the powerpc 970 (g5) actually
I hate big endian
little endian mode was a concession to microsoft so when microsoft deported windows from powerpc, that was the end of that
m68k was a beautiful arch
wdym was
Who uses it but fadanoid and I
Also obos' WIP branch hasn't updated any m68k things
So it fails to compile
the powermac g5 can support kvm on linux so that's the important thing, that makes for a pleasant medium between emulation and native, one where the subtleties of the architecture leak through but you still have the conveniences of qemu
damn there is even a powerpc kvm?
it's very popular
nice
fadanoid what do u think of this
i approve, this will make for interesting comparisons
well thanks for your input
i think uacpi will benefit from cultivating its corporate identity by introducing distinctive textual expressions of its philosophy
lol
you can even put up a pretentious branding page about it
and a blogpost to hn
does ACPICA do that printout in the linux boot process where you see the tables?
hmm no i think thats linux
I am pretty sure its acpica, iirc I also saw them when I tried porting acpica to my kernel at some point https://github.com/acpica/acpica/blob/master/source/components/tables/tbprint.c#L251
ohh interesting
i wonder if i should add a printout like this too
more logs more attention to uacpi bigger ego
Indeed, who else could use be using it 🤔
You rewrote your thing, no?
Yeah but the loader still exists
And the arch layer of the rewrite is basically the same anyway, 68k and rv64 support should be trivial once I get the motivation 😔
Anyway I have my own progress thread, I should post an update there lol
my acpica pr finally got merged lol
only a two week delay
should also send into the linux kernel probably
🎉
i wonder if intel kept him on despite you-know-what
his profile still says he's on vacation but not sure
maybe they suspended him and then realised he would be hard to replace and decided to weather the angry corvette owners sending them emails demanding his head
lmao
or maybe he is gone
There's also Robert Moore, who is i guess the OG maintainer, who is mostly doing stuff around the linux kernel these days
maybe they will get him back
acpibob
thats the guy
hmm unlucky test case
[uACPI][TRACE] load of 'DSDT' (OEM ID 'uTEST' OEM Table ID 'RUNRIDTB')
[uACPI][WARN] BUG: attempting to free an opregion@0000606000000440 with a handler attached
=================================================================
==562==ERROR: AddressSanitizer: heap-use-after-free on address 0x606000000478 at pc 0x55ef1944726d bp 0x7ffee1116720 sp 0x7ffee1116710
READ of size 8 at 0x606000000478 thread T0
#0 0x55ef1944726c in find_previous_region_link /mnt/d/uACPI/source/opregion.c:186
#1 0x55ef19447f2c in region_uninstall_handler /mnt/d/uACPI/source/opregion.c:281
#2 0x55ef19448975 in uacpi_opregion_uninstall_handler /mnt/d/uACPI/source/opregion.c:325
#3 0x55ef1943cf8b in uacpi_namespace_node_uninstall /mnt/d/uACPI/source/namespace.c:404
#4 0x55ef1942f9fb in call_frame_clear /mnt/d/uACPI/source/interpreter.c:4374
#5 0x55ef194388a8 in ctx_reload_post_ret /mnt/d/uACPI/source/interpreter.c:5593
#6 0x55ef194397e3 in uacpi_execute_control_method /mnt/d/uACPI/source/interpreter.c:5712
#7 0x55ef1940a44b in do_load_table /mnt/d/uACPI/source/interpreter.c:1274
#8 0x55ef1940d243 in uacpi_execute_table /mnt/d/uACPI/source/interpreter.c:1539
#9 0x55ef193dcaa2 in uacpi_table_load_with_cause /mnt/d/uACPI/source/tables.c:1063
#10 0x55ef193ebb8f in uacpi_namespace_load /mnt/d/uACPI/source/uacpi.c:371
#11 0x55ef1933676e in run_test /mnt/d/uACPI/tests/runner/test_runner.cpp:480
#12 0x55ef19338b8b in main /mnt/d/uACPI/tests/runner/test_runner.cpp:616
#13 0x7f209ae6bd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#14 0x7f209ae6be3f in __libc_start_main_impl ../csu/libc-start.c:392
forgetting to bump a reference count somewhere i guess?
OperationRegion(MYRE, SystemMemory, 0, 128)
Field (MYRE, AnyAcc, NoLock) {
FILD, 32
}
CopyObject(123, MYRE)
getting closer to a simple reproducer
==598==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x7f40cb2cd887 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55fdca36ffad in uacpi_kernel_alloc /mnt/d/uACPI/tests/runner/interface_impl.cpp:227
#2 0x55fdca457407 in uacpi_install_address_space_handler /mnt/d/uACPI/source/opregion.c:556
#3 0x55fdca45b8ba in uacpi_install_default_address_space_handlers /mnt/d/uACPI/source/default_handlers.c:400
#4 0x55fdca3f869c in uacpi_initialize /mnt/d/uACPI/source/uacpi.c:303
#5 0x55fdca34353c in run_test /mnt/d/uACPI/tests/runner/test_runner.cpp:429
#6 0x55fdca345b8b in main /mnt/d/uACPI/tests/runner/test_runner.cpp:616
#7 0x7f40ca6b1d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
nvm i get it
the opregion handler is uninstalled when a node is removed from the namespace
but here the node gets overwritten so the handler object is just unreferenced and not uninstalled
welcome to this weeks episode of obscure aml edge case that must be solved even though its impossible to encounter in the real world
fixed this bug!
+static uacpi_iteration_decision opregion_detach_from_parent(
+ void *user, uacpi_namespace_node *node, uacpi_u32 node_depth
+)
+{
+ uacpi_object *target_object = user;
+ UACPI_UNUSED(node_depth);
+
+ if (node->object == target_object) {
+ uacpi_opregion_uninstall_handler(node);
+ return UACPI_ITERATION_DECISION_BREAK;
+ }
+
+ return UACPI_ITERATION_DECISION_CONTINUE;
+}
+
static void object_replace_child(uacpi_object *parent, uacpi_object *new_child)
{
+ if (parent->flags == UACPI_REFERENCE_KIND_NAMED &&
+ uacpi_object_is(parent->inner_object, UACPI_OBJECT_OPERATION_REGION)) {
+
+ /*
+ * We're doing a CopyObject or similar to a namespace node. Try to find
+ * the parent node and manually detach the handler.
+ */
+ uacpi_namespace_do_for_each_child(
+ uacpi_namespace_root(), opregion_detach_from_parent, UACPI_NULL,
+ UACPI_OBJECT_OPERATION_REGION_BIT, UACPI_MAX_DEPTH_ANY,
+ UACPI_SHOULD_LOCK_NO, UACPI_PERMANENT_ONLY_NO, parent
+ );
+ }
+
uacpi_object_detach_child(parent);
uacpi_object_attach_child(parent, new_child);
}
it was actually non-trivial as we have to scan the namespace to find the parent namespace node that is responsible for the opregion
So that even when it's an anonymous reference to a named object it still works:
OperationRegion(MYRE, SystemMemory, 0, 128)
Method (REPL, 1) {
Arg0 = 123
}
REPL(RefOf(MYRE))
and this now just times out as expected:
[uACPI][TRACE] load of 'DSDT' (OEM ID 'uTEST ' OEM Table ID 'RUNRIDTB')
[uACPI][ERROR] loop time out after running for 3 seconds
[uACPI][ERROR] aborting method invocation due to previous error: hanging AML while loop
[uACPI][ERROR] #0 in \TEST()
[uACPI][INFO] successfully loaded 1 AML blob in 3001ms (1054988 ops, 351526/s)
this is fixed too
uacpi_initialize(0);
uacpi_namespace_load();
uacpi_namespace_initialize();
uacpi_finalize_gpe_initialization();
// ...
uacpi_install_fixed_event_handler(
UACPI_FIXED_EVENT_TIMER_STATUS,
[](uacpi_handle) -> uacpi_interrupt_ret
{
log::debug("SCI");
return UACPI_INTERRUPT_HANDLED;
}, nullptr
);
before I start debugging why the interrupt isn't triggered, is there anything else I need to do to receive pmtimer SCIs?
@mortal yoke I came up with some nasty test cases for opregions
// Name: CopyObject with Operation Region works
// Expect: int => 0
DefinitionBlock ("", "DSDT", 2, "uTEST", "TESTTABL", 0xF0F0F0F0)
{
Method (REPL, 1) {
Arg0 = 123
}
Method (CAS0) {
OperationRegion(MYRE, SystemMemory, 0, 128)
Field (MYRE, AnyAcc, NoLock) {
FILD, 32
}
FILD = 1
CopyObject(123, MYRE)
}
CAS0()
Method (CAS1) {
OperationRegion(MYRE, SystemMemory, 0, 128)
Field (MYRE, AnyAcc, NoLock) {
FILD, 32
}
FILD = 1
REPL(RefOf(MYRE))
}
CAS1()
Method (CAS2) {
OperationRegion(MYRE, SystemMemory, 0, 128)
Field (MYRE, AnyAcc, NoLock) {
FILD, 32
}
FILD = 1
Name (FAKE, 123)
CopyObject(MYRE, FAKE)
Field (FAKE, AnyAcc, NoLock) {
FAKF, 32
}
REPL(RefOf(MYRE))
FAKF = 1
}
CAS2()
Method (CAS3) {
OperationRegion(MYR0, SystemMemory, 0, 128)
OperationRegion(MYR1, SystemMemory, 0, 128)
CopyObject(123, MYR1)
}
CAS3()
Method (CAS4) {
OperationRegion(MYRE, SystemMemory, 0, 128)
Field (MYRE, AnyAcc, NoLock) {
FILD, 32
}
FILD = 1
CopyObject(FILD, MYRE)
FILD = 1
}
CAS4()
Name (MAIN, 0)
}
Give this a try
@fiery turtle
this should be enough
do u receive other SCIs, like the power button?
try installing that
does qemu's "power down" send that?
yup
I'm not receiving it either
yeah then its a bug on your side
happy to report all of thse work in uACPI now:
[uACPI][TRACE] load of 'DSDT' (OEM ID 'uTEST ' OEM Table ID 'TESTTABL')
[uACPI][TRACE] write to [\CAS0.MYRE] (1 bytes) SystemMemory[0x0000000000000000] = 0x1
[uACPI][TRACE] write to [\CAS0.MYRE] (1 bytes) SystemMemory[0x0000000000000001] = 0x0
[uACPI][TRACE] write to [\CAS0.MYRE] (1 bytes) SystemMemory[0x0000000000000002] = 0x0
[uACPI][TRACE] write to [\CAS0.MYRE] (1 bytes) SystemMemory[0x0000000000000003] = 0x0
[uACPI][TRACE] write to [\CAS1.MYRE] (1 bytes) SystemMemory[0x0000000000000000] = 0x1
[uACPI][TRACE] write to [\CAS1.MYRE] (1 bytes) SystemMemory[0x0000000000000001] = 0x0
[uACPI][TRACE] write to [\CAS1.MYRE] (1 bytes) SystemMemory[0x0000000000000002] = 0x0
[uACPI][TRACE] write to [\CAS1.MYRE] (1 bytes) SystemMemory[0x0000000000000003] = 0x0
[uACPI][TRACE] write to [\CAS2.MYRE] (1 bytes) SystemMemory[0x0000000000000000] = 0x1
[uACPI][TRACE] write to [\CAS2.MYRE] (1 bytes) SystemMemory[0x0000000000000001] = 0x0
[uACPI][TRACE] write to [\CAS2.MYRE] (1 bytes) SystemMemory[0x0000000000000002] = 0x0
[uACPI][TRACE] write to [\CAS2.MYRE] (1 bytes) SystemMemory[0x0000000000000003] = 0x0
[uACPI][ERROR] unable to attach (SystemMemory) operation region \CAS2.FAKE: no handler found
[uACPI][ERROR] aborting method invocation due to previous error: no handler found
[uACPI][ERROR] #0 in \CAS2()
[uACPI][TRACE] write to [\CAS4.MYRE] (1 bytes) SystemMemory[0x0000000000000000] = 0x1
[uACPI][TRACE] write to [\CAS4.MYRE] (1 bytes) SystemMemory[0x0000000000000001] = 0x0
[uACPI][TRACE] write to [\CAS4.MYRE] (1 bytes) SystemMemory[0x0000000000000002] = 0x0
[uACPI][TRACE] write to [\CAS4.MYRE] (1 bytes) SystemMemory[0x0000000000000003] = 0x0
[uACPI][TRACE] read from [\CAS4.MYRE] (1 bytes) SystemMemory[0x0000000000000000] = 0x1
[uACPI][TRACE] read from [\CAS4.MYRE] (1 bytes) SystemMemory[0x0000000000000001] = 0x0
[uACPI][TRACE] read from [\CAS4.MYRE] (1 bytes) SystemMemory[0x0000000000000002] = 0x0
[uACPI][TRACE] read from [\CAS4.MYRE] (1 bytes) SystemMemory[0x0000000000000003] = 0x0
[uACPI][ERROR] unable to attach (<unknown>) operation region \CAS4.MYRE: invalid argument
[uACPI][ERROR] aborting method invocation due to previous error: invalid argument
[uACPI][ERROR] #0 in \CAS4()
[uACPI][TRACE] load of 'SSDT' (OEM ID 'uTEST ' OEM Table ID 'RUNRIDTB')
[uACPI][TRACE] [AML DEBUG] String => "TestRunner ID SSDT loaded!"
[uACPI][INFO] successfully loaded 2 AML blobs in 2ms (85 ops, 30504/s)
[uACPI][TRACE] initialized GPE block _GPE[0->128], 0 AML handlers (IRQ 0)
[uACPI][TRACE] initialized GPE block _GPE[128->256], 0 AML handlers (IRQ 0)
[uACPI][TRACE] fixed event 0 enabled successfully
[uACPI][TRACE] activated all 'EmbeddedControl' opregions controlled by '\ ', 0 _REG() calls (0 errors)
[uACPI][TRACE] activated all 'PCI_Config' opregions controlled by '\ ', 0 _REG() calls (0 errors)
[uACPI][INFO] namespace initialization done in 0ms: 0 devices, 0 thermal zones
[uACPI][TRACE] _STA calls: 0 (0 errors), _INI calls: 0 (0 errors)
[uACPI][TRACE] fixed event 0 disabled successfully
no leaks, no UAFs
does using pic instead of ioapic have anything to do with it
or does it not matter
I don't think it should
is there like a qemu info pic thing?
could look what that says
but shouldnt matter i think
info irq i think?
what do those regs mean?
I'm trying to find that out
info irq might be better
it tells you which irqs have been triggered and how many times
I mean, looks like all of them are masked lel
thats ioapic tho
I'm working on that
sci is supposed to be 9
but it's not triggered
wth is i8259
pic
Pic
pic
pic
Mint do you have a bpf on PC related related questions lol
maybe sci is routed exclusively via ioapic on qemu, who knows
maybe
I guess I'll find out in a few days, when I have the time
yeah
i mean these fixed events worked for everyone
including astral, managarm and obos
Do you have pic interrupts for other hardware?
pit works
nothing else yet
just a coincidence i had it opened rn
I guess you could boot Linux with noapic and see if it gets the shutdown button from qemu
you can do ACPI without the apic on qemu
that's how the LAI test image did it and it worked fine (using the PIC)
Elixir Cross Referencer - source code of Qemu v9.1.2: hw/isa/lpc_ich9.c
yeah looks like it allocates a normal irq vector
should work with pic
Yeah it has zero reason to do something else lel
oh wait
I install it like any other interrupt and unmask it 
if (irq >= ICH9_LPC_PIC_NUM_PINS) {
ich9_lpc_update_apic(lpc, irq);
} else {
ich9_lpc_update_pic(lpc, irq);
}
hm?
Doesn't it always gets allocated as 9
well the version im looking at doesnt have a hardcoded number
Elixir Cross Referencer - source code of Qemu v9.1.2: hw/isa/lpc_ich9.c
but yeah i believe this
@torpid root are u using q35?
yes
what if u remove it
still no sci
must be some other skill issue
perchance
if u build qemu u can try setting breakpoint on ich9_set_sci
Those are apic registers
it literally says pic
*ioapic
Mb
The pin, then the raw value, then the decoded fields
the bottom two are pic
I know
and what do those regs mean?
irr is incoming irqs
isr is the irq being served
Irq base is the irq you rebased the pic to
imr is the interrupt mask register
rr_sle elcr fnm
it says 01 for liobilo
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
On which pic?
0
"power down" works on linux
Where you forget to send an eoi
Well ofc it does
I added noapic
u mean the pic driver
u can do cat /proc/interrupts to see sci stats, maybe that will highlight something
what is there to be bugged
who knows
io::out<8>(port::master_command, cmd::icw1_init | cmd::icw1_icw4);
io::out<8>(port::slave_command, cmd::icw1_init | cmd::icw1_icw4);
io::out<8>(port::master_data, 0x20);
io::out<8>(port::slave_data, 0x28);
io::out<8>(port::master_data, 0x04);
io::out<8>(port::slave_data, 0x02);
io::out<8>(port::master_data, cmd::icw4_8086);
io::out<8>(port::slave_data, cmd::icw4_8086);
// ...
// unmask
// vector = 0x20 + 9 = 41
auto port = port::master_data;
auto irq = vector - 0x20;
if (irq >= 8) {
port = port::slave_data;
irq -= 8;
}
io::out<8>(port, io::in<8>(port) & ~(1 << irq));
literally just this
can you show your install irq handler? maybe we could spot something
the uacpi one?
uacpi_status uacpi_kernel_install_interrupt_handler(uacpi_u32 irq, uacpi_interrupt_handler func, uacpi_handle ctx, uacpi_handle *out_irq_handle)
{
auto vector = irq + 0x20;
auto handler = interrupts::get(cpu::bsp_idx, vector).value();
if (handler.get().used())
lib::panic("Requested uACPI interrupt vector {} is already in use", vector);
handler.get().set([](cpu::registers *, auto func, auto ctx) { func(ctx); }, func, ctx);
interrupts::unmask(vector);
*reinterpret_cast<std::size_t *>(out_irq_handle) = vector;
return UACPI_STATUS_OK;
}
interrupts unmask just calls the pic unmask in this case
hmm
please tell me that fixed events need uacpi read/write pci functions implemented
they dont
but i mean maybe since it aborted some _INI methods because u dont implement those some init is not complete
just returning UACPI_STATUS_OK doesn't work
I might have an acute case of skill issue
are your io read/write handlers correct?
I believe they are
double check because io is how those fixed events are configured
looks correct at a glance
wait
unsigned integral
how is in<8> resolved into uint8_t?
i dont see this used there tho?
if constexpr (std::same_as<Type, std::uint8_t>)
asm volatile ("out %w1, %b0" :: "a"(_val), "Nd"(_port));
else if constexpr (std::same_as<Type, std::uint16_t>)
asm volatile ("out %w1, %w0" :: "a"(_val), "Nd"(_port));
else if constexpr (std::same_as<Type, std::uint32_t>)
asm volatile ("out %w1, %0" :: "a"(_val), "Nd"(_port));
is this correct?
should be
hmm
what if u just hardcode it to this
just for testing
0000000000401130 <void tst<unsigned char>()>:
401130: 55 push %rbp
401131: 48 89 e5 mov %rsp,%rbp
401134: c6 45 ff 7b movb $0x7b,-0x1(%rbp)
401138: 66 c7 45 fc 7b 00 movw $0x7b,-0x4(%rbp)
40113e: 8a 45 ff mov -0x1(%rbp),%al
401141: 66 8b 55 fc mov -0x4(%rbp),%dx
401145: ee out %al,(%dx)
401146: 5d pop %rbp
401147: c3 ret
401148: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1)
40114f: 00
0000000000401150 <void tst<unsigned short>()>:
401150: 55 push %rbp
401151: 48 89 e5 mov %rsp,%rbp
401154: 66 c7 45 fe 7b 00 movw $0x7b,-0x2(%rbp)
40115a: 66 c7 45 fc 7b 00 movw $0x7b,-0x4(%rbp)
401160: 66 8b 45 fe mov -0x2(%rbp),%ax
401164: 66 8b 55 fc mov -0x4(%rbp),%dx
401168: 66 ef out %ax,(%dx)
40116a: 5d pop %rbp
40116b: c3 ret
40116c: 0f 1f 40 00 nopl 0x0(%rax)
0000000000401170 <void tst<unsigned int>()>:
401170: 55 push %rbp
401171: 48 89 e5 mov %rsp,%rbp
401174: c7 45 fc 7b 00 00 00 movl $0x7b,-0x4(%rbp)
40117b: 66 c7 45 fa 7b 00 movw $0x7b,-0x6(%rbp)
401181: 8b 45 fc mov -0x4(%rbp),%eax
401184: 66 8b 55 fa mov -0x6(%rbp),%dx
401188: ef out %eax,(%dx)
401189: 5d pop %rbp
40118a: c3 ret
al ax eax
seems correct
hm
alright
i mean who knows
hmmm how do I use att syntax when I compile with -masm=intel
something like .intel_syntax noprefix
.att_syntax prefix
lol
not an io issue
damn
really interesting
can u make a hacky pci r/w impl?
grasping at straws here ofc
Good night
Yeah like at this point idk what it can be other than a pic bug
Or could be a mapping bug and uacpi getting an incorrect register offset
Thats easy to check by just tracing what io writes uacpi does in a working kernel and this one
The mapping function does look rather complicated, I wonder if there's a bug there
the last one leaks the opregion in qacpi
actually yeah the last write is not right either ```
qacpi_os_mmio_read1 0x50b000002880
qacpi_os_mmio_write1 0x50b000002880 = 0x1
qacpi_os_mmio_read1 0x50b000002881
qacpi_os_mmio_write1 0x50b000002881 = 0
qacpi_os_mmio_read1 0x50b000002882
qacpi_os_mmio_write1 0x50b000002882 = 0
qacpi_os_mmio_read1 0x50b000002883
qacpi_os_mmio_write1 0x50b000002883 = 0
I don't really check that the region object is an opregion, ig I could do that (or alternatively after having implemented wrapper refs for named objects the field could reference the actual underlying region object but idk if that's correct)
my fields reference a namespace node
and on access time they try to get the opregion object
if that fails it just -EINVAL
but your approach is different iirc in that u support writes to opregions that have been deleted basically
(irr & ~imr) != 0 usually means you're forgetting to send an eoi
although considering isr is 0 you probably just have flags.if disabled
could it be showing info during handling an interrupt and before eoi
interrupts are enabled
sure but if your interrupt handlers are taking so much time that that's at all likely you have a bigger issue
nothing spectacular here
yeah I can't reproduce irr not being 0
maybe you got extremely lucky with timing
probably
I don't think this is the issue considering isr for both pics is 0 but SCI is IRQ9 right? if so, you need to unmask IRQ2 since that's used for cascading
unmasking does nothing unfortunately, but why would that matter?
wait I got irq 9 after pressing the power down button
but it's not triggered
and it doesn't get higher than 1 if pressed multiple times
probably bc its not signaled eoi which is caused by not triggering your interrupt handler
the 2nd pic chip signals its interrupt status to the 1st using IRQ2, so if IRQ2 is masked you don't receive any interrupts from the 2nd chip
hmm yes but i didn't know the mask affected that
every irq that's triggered gets eoi ed
so it's not calling the code
if it's not triggering any of your interrupt code I'd look at the pic regs again
I fixed it
I was masking everything then unmasking what I needed, including irq 2.
now I just saved the previous mask and rewrote it after initialising pic
why is that an issue, I don't know
if the second pic gets a interrupt you need to eoi to both pics
I know
so your handler isnt called?
It is now
^
thats some weird shit the pic does
so everything works now?
yes
nice
thanks for help
I wouldn't think it was pic's fault myself
why is what an issue specifically
did u think it worked cumulatively?
so I was initialising the pic, masking every irq and then unmasking whatever I needed. it didn't work.
now I save the masks, init pic, restore masks
I'm not at pc but I'll check in a bit
hmm everything is masked
maybe I messed something up idk
0b11111111 0b11111111
master and slave masks
well it works fine now so idc 
yeah probably
but nice that it works now
going to merge this today
30 commits of fixes, thread safety, new features and api improvements
and also a bunch of new test cases
#1061407633745125397 message
what kind of changes are needed in the kernel apis?
mutex_acquire returns a status instead of bool, get_ticks gets a different name and returns actual nanoseconds and not 100ns fractions
i dont think managarm uses any other apis that i changed, namely namespace iteration stuff
also i still haven't merged it, it's all in the thread-safety branch
it doesnt even get past namespace init in obos?
I should at least see how fast it is on qemu
Maybe it does
It works there
Also new kde update on my computer broke everything


